@Override
  protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);

    String pp = getPropertyPrefix();
    // b.setOpaque(QuaquaManager.getBoolean(pp+"opaque"));
    QuaquaUtilities.installProperty(b, "opaque", UIManager.get(pp + "opaque"));
    b.setRequestFocusEnabled(UIManager.getBoolean(pp + "requestFocusEnabled"));
    b.setFocusable(UIManager.getBoolean(pp + "focusable"));
  }
Example #2
0
  private JComponent addItem(
      final Component pComponent, final KToolbarImpl pToolbar, final Action pAction) {
    JComponent item = null;
    final String key = (String) pAction.getValue(Action.NAME);

    if (pAction instanceof KMenu) {
      final KMenu actionMenu = (KMenu) pAction;
      item = actionMenu.create(pComponent);
      pToolbar.add(item);
    } else if (pAction == KAction.SEPARATOR) {
      pToolbar.addSeparator();
    } else if (pAction instanceof KComponentAction) {
      item = ((KComponentAction) pAction).getComponent();
      pToolbar.add(item);
    } else {
      AbstractButton button;
      ActionGroup group = (ActionGroup) pAction.getValue(KAction.KEY_GROUP);
      if (group != null) {
        button = new JToggleButton(pAction);
        ((JToggleButton) button).setSelected(group.getSelected() == pAction);
        ButtonGroup bg = group.getButtonGroup(ResKey.TOOLBAR);
        bg.add(button);
      } else {
        button = new JButton(pAction);
      }
      item = button;

      final WidgetResources wr = ResourceAdapter.getInstance().getWidget(key, ResKey.TOOLBAR);
      Icon icon = wr.getIcon();
      if (icon == null) {
        icon = DEF_ICON;
      }
      button.setIcon(icon);
      button.setToolTipText(wr.getToolTip());
      button.setMargin(ZERO_INSETS);
      button.setRequestFocusEnabled(false);
      button.setFocusable(false);

      if (false) {
        button.setText(wr.getText());
        button.setMnemonic(wr.getMnenomnic());
        button.setDisplayedMnemonicIndex(wr.getMnenomnicIndex());
      } else {
        button.setText(null);
      }
    }

    if (item != null) {
      pToolbar.add(item);
    }
    return item;
  }
Example #3
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);
       }
     }
   }
 }
Example #4
0
  @Override
  public void installUI(JComponent c) {
    AbstractButton button = (AbstractButton) c;

    ButtonInfo info = new ButtonInfo(button, this);
    button.putClientProperty(BUTTON_INFO_KEY, info);

    button.addMouseListener(info.basicListener);
    button.addMouseMotionListener(info.basicListener);
    button.addFocusListener(info.basicListener);
    button.addPropertyChangeListener(info.basicListener);
    button.addChangeListener(info.basicListener);
    button.addKeyListener(focusArrowListener);
    button.addComponentListener(componentListener);
    button.addKeyListener(keyArmingListener);
    button.setRequestFocusEnabled(false);
    button.setFocusable(true);
    button.addPropertyChangeListener(positionAndShapeListener);
    button.setOpaque(false);
    button.setRolloverEnabled(true);

    if (button.getIcon() != null) {
      Font font = UIManager.getFont("IconButton.font");
      if (font != null) button.setFont(font); // miniature-ish
    }

    super.installUI(c);

    updateLayout(button, info);

    if (button.getFont() == null) {
      Font font = UIManager.getFont("Button.font");
      if (font == null) {
        font = new Font("Default", 0, 13);
      }
      button.setFont(font);
    }
  }