JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.swing
Class ToggleAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by net.sf.japi.swing.ToggleAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public final class ToggleAction
extends AbstractAction

The ToggleAction works similar as an ReflectionAction. But it keeps track of the components. Be sure to use its factory methodsA

Author:
Christian Hujer
See Also:
Serialized Form

Field Summary
static String REFLECTION_PROPERTY_NAME
          The key used for storing the target object's boolean property name to find the methods Value Type: String.
static String REFLECTION_TARGET
          The key used for storing the target object to invoke the methods on.
 
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()
           
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when an action occurs.
protected  Object clone()
          Clones the abstract action.
 JCheckBox createCheckBox()
          Create a JCheckBox for this action.
 JCheckBoxMenuItem createCheckBoxMenuItem()
          Create a JCheckBoxMenuItem.
 boolean isSelected()
          Returns the state of the action.
 void putValue(String key, Object newValue)
          Sets the Value associated with the specified key. This implementation checks the type of newValue if the key is REFLECTION_TARGET or REFLECTION_PROPERTY_NAME, so you'll know of errors quite soon.
 void setSelected(boolean selected)
          Update the selected state.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFLECTION_TARGET

public static final String REFLECTION_TARGET
The key used for storing the target object to invoke the methods on. Value Type: Object.

See Also:
Constant Field Values

REFLECTION_PROPERTY_NAME

public static final String REFLECTION_PROPERTY_NAME
The key used for storing the target object's boolean property name to find the methods Value Type: String.

See Also:
Constant Field Values
Constructor Detail

ToggleAction

public ToggleAction()
Method Detail

isSelected

public boolean isSelected()
Returns the state of the action.

Returns:
selected state of this action

actionPerformed

public void actionPerformed(ActionEvent e)
Invoked when an action occurs.


clone

protected Object clone()
                throws CloneNotSupportedException
Clones the abstract action. This gives the clone its own copy of the key/value list, which is not handled for you by Object.clone().

Overrides:
clone in class AbstractAction
Returns:
a clone of this instance.
Throws:
CloneNotSupportedException - if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
See Also:
Cloneable

createCheckBox

public JCheckBox createCheckBox()
Create a JCheckBox for this action.

Returns:
JCheckBox for this action

createCheckBoxMenuItem

public JCheckBoxMenuItem createCheckBoxMenuItem()
Create a JCheckBoxMenuItem.

Returns:
JCheckBoxMenuItem for this action

putValue

public void putValue(String key,
                     Object newValue)
              throws IllegalArgumentException
Sets the Value associated with the specified key. This implementation checks the type of newValue if the key is REFLECTION_TARGET or REFLECTION_PROPERTY_NAME, so you'll know of errors quite soon.

Specified by:
putValue in interface Action
Overrides:
putValue in class AbstractAction
Parameters:
key - the String that identifies the stored object
newValue - the Object to store using this key
Throws:
IllegalArgumentException - if newValue is of the wrong type
See Also:
Action.putValue(java.lang.String, java.lang.Object)

setSelected

public void setSelected(boolean selected)
Update the selected state.

Parameters:
selected - new selected state

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright