org.jdesktop.swingx.action
Class BoundAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jdesktop.swingx.action.AbstractActionExt
          extended by org.jdesktop.swingx.action.BoundAction
All Implemented Interfaces:
ActionListener, ItemListener, Serializable, Cloneable, EventListener, Action

public class BoundAction
extends AbstractActionExt

A class that represents the many type of actions that this framework supports.

The command invocation of this action may be delegated to another action or item state listener. If there isn't an explicit binding then the command is forwarded to the TargetManager.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jdesktop.swingx.action.AbstractActionExt
GROUP, IS_STATE, LARGE_ICON
 
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
BoundAction()
           
BoundAction(String name)
           
BoundAction(String name, Icon icon)
           
BoundAction(String name, String command)
           
BoundAction(String name, String command, Icon icon)
           
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Callback for command actions.
 void addActionListener(ActionListener listener)
          Add an action listener which will be invoked when this action is invoked.
 void addItemListener(ItemListener listener)
          Add an item listener which will be invoked for toggle actions.
 ActionListener[] getActionListeners()
           
 ItemListener[] getItemListeners()
           
 void itemStateChanged(ItemEvent evt)
          Callback for toggle actions.
 void registerCallback(Object handler, String method)
          Registers a callback method when the Action corresponding to the action id is invoked.
 void removeActionListener(ActionListener listener)
           
 void removeItemListener(ItemListener listener)
           
 void setCallback(String callback)
          The callback string will be called to register the action callback.
 
Methods inherited from class org.jdesktop.swingx.action.AbstractActionExt
dispose, getAccelerator, getActionCommand, getGroup, getLargeIcon, getLongDescription, getMnemonic, getName, getShortDescription, getSmallIcon, isSelected, isStateAction, setAccelerator, setActionCommand, setGroup, setLargeIcon, setLongDescription, setMnemonic, setMnemonic, setName, setSelected, setShortDescription, setSmallIcon, setStateAction, setStateAction, toString
 
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, wait, wait, wait
 

Constructor Detail

BoundAction

public BoundAction()

BoundAction

public BoundAction(String name)

BoundAction

public BoundAction(String name,
                   String command)
Parameters:
name - display name of the action
command - the value of the action command key

BoundAction

public BoundAction(String name,
                   Icon icon)

BoundAction

public BoundAction(String name,
                   String command,
                   Icon icon)
Parameters:
name - display name of the action
command - the value of the action command key
icon - icon to display
Method Detail

setCallback

public void setCallback(String callback)
The callback string will be called to register the action callback. Note the toggle property must be set if this is a state action before this method is called. For example,
     <exec>com.sun.foo.FubarHandler#handleBar</exec>
 
will register
     registerCallback(com.sun.foo.FubarHandler(), "handleBar");
 


registerCallback

public void registerCallback(Object handler,
                             String method)
Registers a callback method when the Action corresponding to the action id is invoked. When a Component that was constructed from the Action identified by the action id invokes actionPerformed then the method named will be invoked on the handler Object.

If the Action represented by the action id is a StateChangeAction, then the method passed should take an int as an argument. The value of getStateChange() on the ItemEvent object will be passed as the parameter.

Parameters:
handler - the object which will be perform the action
method - the name of the method on the handler which will be called.

addActionListener

public void addActionListener(ActionListener listener)
Add an action listener which will be invoked when this action is invoked.


removeActionListener

public void removeActionListener(ActionListener listener)

getActionListeners

public ActionListener[] getActionListeners()

addItemListener

public void addItemListener(ItemListener listener)
Add an item listener which will be invoked for toggle actions.


removeItemListener

public void removeItemListener(ItemListener listener)

getItemListeners

public ItemListener[] getItemListeners()

actionPerformed

public void actionPerformed(ActionEvent evt)
Callback for command actions.


itemStateChanged

public void itemStateChanged(ItemEvent evt)
Callback for toggle actions.

Specified by:
itemStateChanged in interface ItemListener
Overrides:
itemStateChanged in class AbstractActionExt
Parameters:
evt - the ItemEvent fired by a ItemSelectable on changing the selected state.