Class ActionRepeatableButtonModel
- java.lang.Object
-
- javax.swing.DefaultButtonModel
-
- org.pushingpixels.radiance.component.api.common.model.ActionRepeatableButtonModel
-
- All Implemented Interfaces:
java.awt.ItemSelectable,java.io.Serializable,javax.swing.ButtonModel,ActionButtonModel
public class ActionRepeatableButtonModel extends javax.swing.DefaultButtonModel implements ActionButtonModel
Extension of the default button model that supports theActionButtonModelinterface and repeated invocation of action listeners on mouse rollover. This is the default core action model set onJCommandButtons.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.TimerautoRepeatTimerTimer for the auto-repeat action mode.private JCommandButtoncommandButtonThe button behind the model.private booleantoFireActionOnPressIndication whether the action is fired on mouse press (as opposed to mouse release).
-
Constructor Summary
Constructors Constructor Description ActionRepeatableButtonModel(JCommandButton commandButton)Creates a new button model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanisActionTimerRunning()Checks whether the action timer is running.booleanisFireActionOnPress()Returns indication whether the associated actions should be fired on mouse press instead of mouse release.booleanisSelected()voidsetFireActionOnPress(boolean toFireActionOnPress)Sets indication whether the associated actions should be fired on mouse press instead of mouse release.voidsetPressed(boolean b)voidsetRollover(boolean b)voidsetSelected(boolean b)private voidstartActionTimer(int modifiers)Starts the action timer, passing the specified modifiers to the action event that will be fired in a loop.private voidstopActionTimer()Stop the action timer.-
Methods inherited from class javax.swing.DefaultButtonModel
addActionListener, addChangeListener, addItemListener, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getActionListeners, getChangeListeners, getGroup, getItemListeners, getListeners, getMnemonic, getSelectedObjects, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setArmed, setEnabled, setGroup, setMnemonic
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.ButtonModel
addActionListener, addChangeListener, addItemListener, getActionCommand, getMnemonic, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setArmed, setEnabled, setGroup, setMnemonic
-
-
-
-
Field Detail
-
commandButton
private JCommandButton commandButton
The button behind the model.
-
autoRepeatTimer
private javax.swing.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 Detail
-
ActionRepeatableButtonModel
public ActionRepeatableButtonModel(JCommandButton commandButton)
Creates a new button model.- Parameters:
commandButton- The associated command button.
-
-
Method Detail
-
isSelected
public boolean isSelected()
- Specified by:
isSelectedin interfacejavax.swing.ButtonModel- Overrides:
isSelectedin classjavax.swing.DefaultButtonModel
-
setSelected
public void setSelected(boolean b)
- Specified by:
setSelectedin interfacejavax.swing.ButtonModel- Overrides:
setSelectedin classjavax.swing.DefaultButtonModel
-
setPressed
public void setPressed(boolean b)
- Specified by:
setPressedin interfacejavax.swing.ButtonModel- Overrides:
setPressedin classjavax.swing.DefaultButtonModel
-
setRollover
public void setRollover(boolean b)
- Specified by:
setRolloverin interfacejavax.swing.ButtonModel- Overrides:
setRolloverin classjavax.swing.DefaultButtonModel
-
stopActionTimer
private void stopActionTimer()
Stop the action timer.
-
isActionTimerRunning
private boolean isActionTimerRunning()
Checks whether the action timer is running.- Returns:
trueif the action timer is running,falseotherwise.
-
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:ActionButtonModelReturns indication whether the associated actions should be fired on mouse press instead of mouse release.- Specified by:
isFireActionOnPressin interfaceActionButtonModel- Returns:
trueif the associated actions are fired on mouse press,falseif the associated actions are fired on mouse release.
-
setFireActionOnPress
public void setFireActionOnPress(boolean toFireActionOnPress)
Description copied from interface:ActionButtonModelSets indication whether the associated actions should be fired on mouse press instead of mouse release.- Specified by:
setFireActionOnPressin interfaceActionButtonModel- Parameters:
toFireActionOnPress- iftrue, the associated actions will be fired on mouse press, otherwise the associated actions will be fired on mouse release.
-
-