Exemplo n.º 1
0
 /**
  * Returns the baseline.
  *
  * @throws NullPointerException {@inheritDoc}
  * @throws IllegalArgumentException {@inheritDoc}
  * @see javax.swing.JComponent#getBaseline(int, int)
  * @since 1.6
  */
 public int getBaseline(JComponent c, int width, int height) {
   super.getBaseline(c, width, height);
   AbstractButton b = (AbstractButton) c;
   String text = b.getText();
   if (text == null || "".equals(text)) {
     return -1;
   }
   FontMetrics fm = b.getFontMetrics(b.getFont());
   layout(b, fm, width, height);
   return BasicHTML.getBaseline(b, textRect.y, fm.getAscent(), textRect.width, textRect.height);
 }
Exemplo n.º 2
0
 /**
  * Returns an enum indicating how the baseline of the component changes as the size changes.
  *
  * @throws NullPointerException {@inheritDoc}
  * @see javax.swing.JComponent#getBaseline(int, int)
  * @since 1.6
  */
 public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
   super.getBaselineResizeBehavior(c);
   if (c.getClientProperty(BasicHTML.propertyKey) != null) {
     return Component.BaselineResizeBehavior.OTHER;
   }
   switch (((AbstractButton) c).getVerticalAlignment()) {
     case AbstractButton.TOP:
       return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
     case AbstractButton.BOTTOM:
       return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
     case AbstractButton.CENTER:
       return Component.BaselineResizeBehavior.CENTER_OFFSET;
   }
   return Component.BaselineResizeBehavior.OTHER;
 }
Exemplo n.º 3
0
  @Override
  public void uninstallUI(JComponent c) {
    AbstractButton button = (AbstractButton) c;

    ButtonInfo info = getButtonInfo(button);

    button.removeMouseListener(info.basicListener);
    button.removeMouseMotionListener(info.basicListener);
    button.removeFocusListener(info.basicListener);
    button.removePropertyChangeListener(info.basicListener);
    button.removeChangeListener(info.basicListener);
    button.removeKeyListener(focusArrowListener);
    button.removeComponentListener(componentListener);
    button.removeKeyListener(keyArmingListener);
    button.removePropertyChangeListener(positionAndShapeListener);

    super.uninstallUI(c);
  }
Exemplo n.º 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);
    }
  }
Exemplo n.º 5
0
 public SpecialUIButton(ButtonUI ui) {
   this.ui = ui;
   ui.installUI(this);
 }