org.progeeks.util.swing
Class CheckBoxAction
java.lang.Object
javax.swing.AbstractAction
org.progeeks.util.swing.CheckBoxAction
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
public class CheckBoxAction
- extends javax.swing.AbstractAction
- implements java.lang.Cloneable
Extends the standard Swing action to provide check-box support.
If you override isChecked()/setChecked() then you should not do
any check processing in the action performed. If you override
actionPerformed() and handle your own toggling, then you should
not override isChecked()/setChecked(). The actionPerformed()
method (depending on the button model) will usually be called
after the check state has changed within the button model. So
it is possible to let the checkbox action handle 100% of the
toggling and simply override the actionPerformed() method to
update the dependent state.
- Version:
- $Revision: 1.8 $
- Author:
- Paul Speed
- See Also:
- Serialized Form
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent event)
Default implementation does nothing since the button
model should be toggling its own state. |
void |
addButtonModel(javax.swing.ButtonModel model)
Attaches this action to the specified button model. |
java.lang.Object |
clone()
|
protected void |
firePropertyChange(java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
Overridden to catch our own property changes. |
boolean |
isChecked()
Returns the checked state of this action. |
void |
removeButtonModel(javax.swing.ButtonModel model)
|
void |
setChecked(boolean checked)
Called to set the action's state to "checked". |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROP_CHECKED
public static final java.lang.String PROP_CHECKED
- See Also:
- Constant Field Values
CheckBoxAction
public CheckBoxAction(java.lang.String name,
boolean checked)
CheckBoxAction
public CheckBoxAction(java.lang.String name)
CheckBoxAction
public CheckBoxAction()
clone
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
- Overrides:
clone
in class javax.swing.AbstractAction
- Throws:
java.lang.CloneNotSupportedException
setChecked
public void setChecked(boolean checked)
- Called to set the action's state to "checked".
isChecked
public boolean isChecked()
- Returns the checked state of this action.
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
- Default implementation does nothing since the button
model should be toggling its own state. With most toggling
button models, the isChecked() state will be changed before
this event is fired. This method can be a convenient place
to detect these changes without having to override and
pass up the setChecked() method.
- Specified by:
actionPerformed
in interface java.awt.event.ActionListener
addButtonModel
public void addButtonModel(javax.swing.ButtonModel model)
- Attaches this action to the specified button model.
State changes to one are reflected in the other.
removeButtonModel
public void removeButtonModel(javax.swing.ButtonModel model)
firePropertyChange
protected void firePropertyChange(java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
- Overridden to catch our own property changes.
- Overrides:
firePropertyChange
in class javax.swing.AbstractAction
Copyright © 2002-2003 Paul Speed. All Rights Reserved.