Example #1
0
 public static AbstractButton makeToolBarButton(Command cmd) {
   AbstractButton b;
   if (cmd instanceof ToggleCommand) {
     b = new JToggleButton(cmd);
     b.setSelected(((ToggleCommand) cmd).isSelected());
   } else {
     b = new JButton(cmd);
   }
   b.setFocusable(false);
   b.setText(null);
   // b.setMargin(new Insets(2, 2, 2, 2));
   b.setBorderPainted(false);
   cmd.bind(b);
   return b;
 }
Example #2
0
 protected void initialiseButton(Action action, AbstractButton btn) {
   if (btn != null) {
     btn.setRequestFocusEnabled(false);
     btn.setText("");
     String tt = null;
     if (action != null) {
       tt = (String) action.getValue(Action.SHORT_DESCRIPTION);
     }
     btn.setToolTipText(tt != null ? tt : "");
     if (action != null) {
       Icon icon = getIconFromAction(action, BaseAction.IBaseActionPropertyNames.ROLLOVER_ICON);
       if (icon != null) {
         btn.setRolloverIcon(icon);
         btn.setRolloverSelectedIcon(icon);
       }
       icon = getIconFromAction(action, BaseAction.IBaseActionPropertyNames.DISABLED_ICON);
       if (icon != null) {
         btn.setDisabledIcon(icon);
       }
     }
   }
 }
 /** @noinspection ALL */
 private void $$$loadButtonText$$$(AbstractButton component, String text) {
   StringBuffer result = new StringBuffer();
   boolean haveMnemonic = false;
   char mnemonic = '\0';
   int mnemonicIndex = -1;
   for (int i = 0; i < text.length(); i++) {
     if (text.charAt(i) == '&') {
       i++;
       if (i == text.length()) break;
       if (!haveMnemonic && text.charAt(i) != '&') {
         haveMnemonic = true;
         mnemonic = text.charAt(i);
         mnemonicIndex = result.length();
       }
     }
     result.append(text.charAt(i));
   }
   component.setText(result.toString());
   if (haveMnemonic) {
     component.setMnemonic(mnemonic);
     component.setDisplayedMnemonicIndex(mnemonicIndex);
   }
 }