Class FlatToggleButton

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, SwingConstants

public class FlatToggleButton extends FlatButton
A flat toggle button.

Selected button can use a specific foreground and icon.

See Also:
  • Constructor Details

    • FlatToggleButton

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

      public FlatToggleButton(boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag)
      Equivalent of FlatToggleButton(null, enablePressedBorder, enableEnteredBorder, enableDrag)
      Parameters:
      enablePressedBorder -
      enableEnteredBorder -
      enableDrag -
    • FlatToggleButton

      @Deprecated public FlatToggleButton(org.openide.util.actions.BooleanStateAction bsa)
      Deprecated.
      Equivalent of FlatToggleButton(bsa, true, true, false)
    • FlatToggleButton

      @Deprecated public FlatToggleButton(org.openide.util.actions.BooleanStateAction bsa, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag)
      Deprecated.
      Create a toggle button initialized with the specified action.
      Parameters:
      bsa -
      enablePressedBorder -
      enableEnteredBorder -
      enableDrag -
    • FlatToggleButton

      public FlatToggleButton(ToggleAction ta)
      Create a toggle button initialized with the specified ToggleAction.
      Parameters:
      ta -
    • FlatToggleButton

      public FlatToggleButton(ToggleAction ta, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag)
      Create a toggle button initialized with the specified ToggleAction.
      Parameters:
      ta -
      enablePressedBorder -
      enableEnteredBorder -
      enableDrag -
  • Method Details

    • isSelected

      public boolean isSelected()
    • setSelected

      public void setSelected(boolean b)
      Change the selected status.

      This does NOT fire a change event. Use doClick() to simulate a user click.

      Parameters:
      b -
    • doClick

      public void doClick()
      Simulate a user click.
    • setIcon

      public void setIcon(Icon icon)
      Redirected to setUnselectedIcon(icon).
      Overrides:
      setIcon in class JLabel
      Parameters:
      icon -
    • setBooleanStateAction

      @Deprecated public void setBooleanStateAction(org.openide.util.actions.BooleanStateAction bsa)
      Deprecated.
      Set the button from a BooleanStateAction.

      When this togglebutton is clicked it just calls action.actionPerformed(). Button selected state will follow the BooleanStateAction.PROP_BOOLEAN_STATE action's property changes.

      Reuse the following properties:
      - "LARGE_ICON_KEY" property => setSelectedIcon()
      - BooleanStateAction.PROP_BOOLEAN_STATE => setSelected()

      Parameters:
      bsa - A non-null BooleanStateAction.
    • setToggleAction

      public void setToggleAction(ToggleAction ta)
      Update button from a ToggleAction.

      When this togglebutton is clicked it just calls action.actionPerformed(). Button selected state will follow the Action.SELECTED_KEY action's property changes.

      Parameters:
      ta -
    • setUnselectedIcon

      public void setUnselectedIcon(Icon icon)
    • getUnselectedIcon

      public Icon getUnselectedIcon()
    • setSelectedIcon

      public void setSelectedIcon(Icon selectedIcon)
    • getSelectedIcon

      public Icon getSelectedIcon()
    • setSelectedForeground

      public void setSelectedForeground(Color c)
    • getSelectedForeground

      public Color getSelectedForeground()
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Overridden to add the support of the LARGE_ICON_KEY and BooleanState property.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class FlatButton
      Parameters:
      evt -