com.jgoodies.uif.action
Class ToggleAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.jgoodies.uif.action.ToggleAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public final class ToggleAction
extends AbstractAction

An Action implementation useful to to create JCheckBoxes, JRadioButtons, JCheckBoxMenuItems and other toggle components. ToggleActions do not perform an action. They provide a toggle state in the ButtonModel and the data required to build toggle components: icon, text, mnemonic, etc.

Version:
$Revision: 1.6 $
Author:
Karsten Lentzsch
See Also:
ButtonModel, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Does nothing.
 ButtonModel createButtonModel()
          Creates and returns a ButtonModel for this ToggleAction.
static ToggleAction createCheck(String actionName, ResourceMap resourceMap, com.jgoodies.binding.value.ValueModel subject)
          Creates and returns a ToggleAction for the given ValueModel.
static ToggleAction createCheck(String actionName, ResourceMap resourceMap, com.jgoodies.binding.value.ValueModel subject, Object selectedValue, Object deselectedValue)
          Creates and returns a ToggleAction for the given ValueModel.
static ToggleAction createRadio(String actionName, ResourceMap resourceMap, com.jgoodies.binding.value.ValueModel subject, Object choice)
          Creates and returns a ToggleAction for the given ValueModel and choice value.
 boolean isCheckAction()
          Checks and answers if this is an action intended for check components.
 boolean isRadioAction()
          Checks and answers if this is an action intended for radio components.
 
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
 

Method Detail

createCheck

public static ToggleAction createCheck(String actionName,
                                       ResourceMap resourceMap,
                                       com.jgoodies.binding.value.ValueModel subject)
Creates and returns a ToggleAction for the given ValueModel. Useful to create JCheckButtons and JCheckButtonMenuItems.

Parameters:
actionName - used to look up action properties in the resource map
resourceMap - provides the action properties: name, icon, etc.
subject - holds the boolean toggle button state
Returns:
an action with an associated ButtonModel that reflects the toggle state of the given subject ValueModel

createCheck

public static ToggleAction createCheck(String actionName,
                                       ResourceMap resourceMap,
                                       com.jgoodies.binding.value.ValueModel subject,
                                       Object selectedValue,
                                       Object deselectedValue)
Creates and returns a ToggleAction for the given ValueModel. Useful to create JCheckButtons and JCheckButtonMenuItems.

Parameters:
actionName - used to look up action properties in the resource map
resourceMap - provides the action properties: name, icon, etc.
subject - holds the boolean toggle button state
selectedValue - the subject value that represents the selected state
deselectedValue - the subject value that represents the deselected state
Returns:
an action with an associated ButtonModel that reflects the toggle state of the given subject ValueModel

createRadio

public static ToggleAction createRadio(String actionName,
                                       ResourceMap resourceMap,
                                       com.jgoodies.binding.value.ValueModel subject,
                                       Object choice)
Creates and returns a ToggleAction for the given ValueModel and choice value. Useful to create JRadioButtons and JRadioButtonMenuItems.

Parameters:
actionName - used to look up action properties in the resource map
resourceMap - provides the action properties: name, icon, etc.
subject - holds the boolean toggle button state
choice - the subject value that represents the selected state
Returns:
an action with an associated ButtonModel that reflects the toggle state of the given subject ValueModel

actionPerformed

public void actionPerformed(ActionEvent evt)
Does nothing. ToggleActions do not perform an action. They provide a state in the ButtonModel and the data required to build toggle components: icon, text, mnemonic, etc.

Parameters:
evt - the ignored event

createButtonModel

public ButtonModel createButtonModel()
Creates and returns a ButtonModel for this ToggleAction.

Returns:
the created ButtonModel

isCheckAction

public boolean isCheckAction()
Checks and answers if this is an action intended for check components. Radio-like actions are used for JRadioButtons and JRadioButtonMenuItems, check-like actions are used for JCheckBoxes and JCheckBoxMenuItems.

Returns:
true for check ToggleActions, false otherwise

isRadioAction

public boolean isRadioAction()
Checks and answers if this is an action intended for radio components. Radio-like actions are used for JRadioButtons and JRadioButtonMenuItems, check-like actions are used for JCheckBoxes and JCheckBoxMenuItems.

Returns:
true for radio ToggleActions, false otherwise


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.