Exemplo n.º 1
0
  /**
   * This method overrides Container's addImpl method. If a JButton is added, it is disabled.
   *
   * @param component The Component to add.
   * @param constraints The Constraints placed on the component.
   * @param index The index to place the Component at.
   */
  protected void addImpl(Component component, Object constraints, int index) {
    // XXX: Sun says disable button but test cases show otherwise.
    super.addImpl(component, constraints, index);

    // if we added a Swing Button then adjust this a little
    if (component instanceof AbstractButton) {
      AbstractButton b = (AbstractButton) component;
      b.setRolloverEnabled(rollover);
    }
  } // addImpl()
Exemplo n.º 2
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);
    }
  }