|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractAction vmm.actions.AbstractActionVMM vmm.actions.ToggleAction
public class ToggleAction
A ToggleAction is an Action that has a boolean-valued property named "ToggleState".
The createCheckBox()
and createCheckBoxMenuItem()
methods return
components whose state is synchronized with each other and with the state of this
ToggleAction. When one of these components generates an ActionEvent, the states of
the ToggleAction and of all the synchronized components are changed to match.
A getState()
method is provided as a convenience to make it possible to
determine the current state. (Note that this is a concrete subclass of AbstractAction,
but its actionPerformed
method is defined to do nothing. It is still possible
to override this method if you want to perform some action when the state changes.)
Field Summary |
---|
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 |
Constructor Summary | |
---|---|
ToggleAction()
Create a ToggleAction with no name or icon and initial state set to false. |
|
ToggleAction(java.lang.String name)
Create a ToggleAction with a given name but no icon and initial state set to false. |
|
ToggleAction(java.lang.String name,
boolean checked)
Create a ToggleAction with a specified name and initial state, and no icon. |
|
ToggleAction(java.lang.String name,
javax.swing.Icon icon)
Create a ToggleAction with a specified name and icon and with state initially set to false. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent evt)
This method implements the abstract method that is inherited from the AbstractAction class, but it is defined to do nothing. |
javax.swing.JCheckBox |
createCheckBox()
Return a JCheckBox whose selection state is synchronized with the state of this ToggleAction and with other components returned by this method and by createCheckBoxMenuItem() . |
javax.swing.JCheckBoxMenuItem |
createCheckBoxMenuItem()
Return a JCheckBoxMenuItem whose selection state is synchronized with the state of this ToggleAction and with other components returned by this method and by createCheckBox() . |
javax.swing.JMenuItem[] |
getMenuItems()
Returns an array containing a single JCheckBoxMenuItem. |
boolean |
getState()
Gets the current state of the ToggleAction. |
void |
setState(boolean state)
Sets the current state of the ToggleAction. |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ToggleAction()
public ToggleAction(java.lang.String name)
name
- If non-null, this string will be set as the Name property of the Action.public ToggleAction(java.lang.String name, boolean checked)
name
- If non-null, this string will be set as the Name property of the Action.checked
- The initial value of the "ToggleState" property.public ToggleAction(java.lang.String name, javax.swing.Icon icon)
name
- If non-null, this string will be set as the Name property of the Action.icon
- If non-null this icon will be set as the Icon property of the Action.Method Detail |
---|
public void actionPerformed(java.awt.event.ActionEvent evt)
public boolean getState()
public void setState(boolean state)
public javax.swing.JCheckBoxMenuItem createCheckBoxMenuItem()
createCheckBox()
.
public javax.swing.JCheckBox createCheckBox()
createCheckBoxMenuItem()
.
public javax.swing.JMenuItem[] getMenuItems()
createCheckBoxMenuItem()
.
getMenuItems
in interface ActionItem
getMenuItems
in class AbstractActionVMM
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |