Class ToggleOrPressButtonModel

All Implemented Interfaces:
ItemSelectable, Serializable, ButtonModel

ToggleOrPressButtonModel handles the storage and maintenance of the state of the button.

Changes the state of the function depending on the locking state of the button.

Modified from http://developer.classpath.org/doc/javax/swing/JToggleButton-source.html

Updates the button state depending if is lockable.

Since:
4.19.6
See Also:
  • Constructor Details

    • ToggleOrPressButtonModel

      public ToggleOrPressButtonModel(JToggleButton button, boolean startLockable)
      Create a new ToggleOrPressButtonModel.
      Parameters:
      button - the button being controlled.
      startLockable - true to start as a toggle button, false to start as a click on / release off button.
  • Method Details

    • setLockable

      public void setLockable(boolean lockable)
      Set button lockable state.

      Lockable on - Normal Toggle button. Lockable off - push on, release off.

      If button is set unlocked when pressed, is de-pressed.

      Parameters:
      lockable - true for lockable, else false.
    • getLockable

      public boolean getLockable()
      Get if Button is Lockable.
      Returns:
      true if normal toggle button, false if push on release off.
    • updateSelected

      public void updateSelected(boolean p)
      An external change has happened so we update.
      Parameters:
      p - new Selected state.
    • setPressed

      public void setPressed(boolean p)
      Sets the pressed state of the button.

      The selected state of the button also changes following the button being pressed.

      Specified by:
      setPressed in interface ButtonModel
      Overrides:
      setPressed in class JToggleButton.ToggleButtonModel
      Parameters:
      p - true if the button is pressed down.