Пример #1
1
 /**
  * Adds human readable shortcuts to the specified string.
  *
  * @param str text of tooltip
  * @param sc shortcut
  * @return tooltip
  */
 public static String addShortcut(final String str, final String sc) {
   if (sc == null || str == null) return str;
   final StringBuilder sb = new StringBuilder();
   for (final String s : sc.split(" ")) {
     String t = "%".equals(s) ? Prop.MAC ? "meta" : "control" : s;
     if (t.length() != 1) t = Toolkit.getProperty("AWT." + t.toLowerCase(Locale.ENGLISH), t);
     sb.append('+').append(t);
   }
   return str + " (" + sb.substring(1) + ')';
 }
Пример #2
1
  /**
   * Sets a mnemomic for the specified button.
   *
   * @param b button
   * @param mnem mnemonics that have already been assigned
   */
  public static void setMnemonic(final AbstractButton b, final StringBuilder mnem) {
    // do not set mnemonics for Mac! Alt+key used for special characters.
    if (Prop.MAC) return;

    // find and assign unused mnemomic
    final String label = b.getText();
    final int ll = label.length();
    for (int l = 0; l < ll; l++) {
      final char ch = Character.toLowerCase(label.charAt(l));
      if (!letter(ch) || mnem.indexOf(Character.toString(ch)) != -1) continue;
      b.setMnemonic(ch);
      mnem.append(ch);
      break;
    }
  }