Class FlatButton

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, SwingConstants
Direct Known Subclasses:
FlatHelpButton, FlatToggleButton

public class FlatButton extends JLabel implements PropertyChangeListener
A very simple button using a JLabel.
See Also:
  • Constructor Details

    • FlatButton

      public FlatButton()
      Equivalent of FlatButton(true, true, false)
    • FlatButton

      public FlatButton(boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag)
      Equivalent to FlatButton(null, enablePressedBorder, enableEnteredBorder, enableDrag).

      Parameters:
      enablePressedBorder -
      enableEnteredBorder -
      enableDrag -
    • FlatButton

      public FlatButton(Action a)
      Equivalent to FlatButton(a, true, true, false).
      Parameters:
      a -
    • FlatButton

      public FlatButton(Action a, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag)
      Create a FlatButton with the specified settings.
      Parameters:
      a - If non null use this action to initialize the button.
      enablePressedBorder - True means a specific border is used when pressed.
      enableEnteredBorder - True means a specific border is used when entered.
      enableDrag - True means mouse drag is possible on this button.
  • Method Details

    • addActionListener

      public void addActionListener(ActionListener l)
      Add an ActionListener which will be called each time button is pressed.

      Parameters:
      l -
    • removeActionListener

      public void removeActionListener(ActionListener l)
    • setAction

      public final void setAction(Action a)
      Configure the button to use the below properties and listen to their changes.

      - NAME > setText()
      - SHORT_DESCRIPTION > setTooltipText()
      - SMALL_ICON > setIcon()
      - "JJazzDisabledIcon" > setDisabledIcon()
      - "enabled" > setEnabled()

      If button is pressed it calls action's actionPerformed() (in addition to the ActionListeners).

      If property "hideActionText" is true, ignore the NAME property.

      Parameters:
      a - A non-null Action.
    • getAction

      public Action getAction()
      The Action associated to this button.
      Returns:
      Null if no action associated.
    • getBorderNothing

      public Border getBorderNothing()
      Returns:
    • getBorderEntered

      public Border getBorderEntered()
      Returns:
      the borderEntered
    • getBorderPressed

      public Border getBorderPressed()
      Returns:
      the borderPressed
    • getToolTipText

      public String getToolTipText()
      Overridden to add "OFF" if disabled.
      Overrides:
      getToolTipText in class JComponent
      Returns:
    • setBorderEntered

      public void setBorderEntered(Border b)
    • setBorderPressed

      public void setBorderPressed(Border b)
    • setBorderNothing

      public void setBorderNothing(Border b)
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener