Class ActionRepeatableButtonModel

java.lang.Object
javax.swing.DefaultButtonModel
org.pushingpixels.radiance.component.api.common.model.ActionRepeatableButtonModel
All Implemented Interfaces:
ItemSelectable, Serializable, ButtonModel, ActionButtonModel

public class ActionRepeatableButtonModel extends DefaultButtonModel implements ActionButtonModel
Extension of the default button model that supports the ActionButtonModel interface and repeated invocation of action listeners on mouse rollover. This is the default core action model set on JCommandButtons.
See Also:
  • Field Details

    • commandButton

      private JCommandButton commandButton
      The button behind the model.
    • autoRepeatTimer

      private Timer autoRepeatTimer
      Timer for the auto-repeat action mode.
    • toFireActionOnPress

      private boolean toFireActionOnPress
      Indication whether the action is fired on mouse press (as opposed to mouse release).
  • Constructor Details

    • ActionRepeatableButtonModel

      public ActionRepeatableButtonModel(JCommandButton commandButton)
      Creates a new button model.
      Parameters:
      commandButton - The associated command button.
  • Method Details

    • isSelected

      public boolean isSelected()
      Specified by:
      isSelected in interface ButtonModel
      Overrides:
      isSelected in class DefaultButtonModel
    • setSelected

      public void setSelected(boolean b)
      Specified by:
      setSelected in interface ButtonModel
      Overrides:
      setSelected in class DefaultButtonModel
    • setPressed

      public void setPressed(boolean b)
      Specified by:
      setPressed in interface ButtonModel
      Overrides:
      setPressed in class DefaultButtonModel
    • setRollover

      public void setRollover(boolean b)
      Specified by:
      setRollover in interface ButtonModel
      Overrides:
      setRollover in class DefaultButtonModel
    • stopActionTimer

      private void stopActionTimer()
      Stop the action timer.
    • isActionTimerRunning

      private boolean isActionTimerRunning()
      Checks whether the action timer is running.
      Returns:
      true if the action timer is running, false otherwise.
    • startActionTimer

      private void startActionTimer(int modifiers)
      Starts the action timer, passing the specified modifiers to the action event that will be fired in a loop.
      Parameters:
      modifiers - Modifiers for the action event to be fired.
    • isFireActionOnPress

      public boolean isFireActionOnPress()
      Description copied from interface: ActionButtonModel
      Returns indication whether the associated actions should be fired on mouse press instead of mouse release.
      Specified by:
      isFireActionOnPress in interface ActionButtonModel
      Returns:
      true if the associated actions are fired on mouse press, false if the associated actions are fired on mouse release.
    • setFireActionOnPress

      public void setFireActionOnPress(boolean toFireActionOnPress)
      Description copied from interface: ActionButtonModel
      Sets indication whether the associated actions should be fired on mouse press instead of mouse release.
      Specified by:
      setFireActionOnPress in interface ActionButtonModel
      Parameters:
      toFireActionOnPress - if true, the associated actions will be fired on mouse press, otherwise the associated actions will be fired on mouse release.