Package org.jdesktop.swingx.action
Class TargetableAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.jdesktop.swingx.action.AbstractActionExt
-
- org.jdesktop.swingx.action.TargetableAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.ItemListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
public class TargetableAction extends AbstractActionExt
A class that represents a dynamically targetable action. The invocation of this action will be dispatched to theTargetManager
instance.You would create instances of this class to let the TargetManager handle the action invocations from the ui components constructed with this action. The TargetManager could be configured depending on application state to handle these actions.
- Author:
- Mark Davidson
- See Also:
TargetManager
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jdesktop.swingx.action.AbstractActionExt
GROUP, IS_STATE, LARGE_ICON
-
-
Constructor Summary
Constructors Constructor Description TargetableAction()
TargetableAction(java.lang.String name)
TargetableAction(java.lang.String name, java.lang.String command)
TargetableAction(java.lang.String name, java.lang.String command, javax.swing.Icon icon)
TargetableAction(java.lang.String name, javax.swing.Icon icon)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent evt)
Callback for command actions.TargetManager
getTargetManager()
Returns the target manager instance which will be used for action dispatch.void
itemStateChanged(java.awt.event.ItemEvent evt)
Callback for toggle actions.void
setTargetManager(TargetManager tm)
Set target manager which will handle this command.java.lang.String
toString()
-
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
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
TargetableAction
public TargetableAction()
-
TargetableAction
public TargetableAction(java.lang.String name)
-
TargetableAction
public TargetableAction(java.lang.String name, java.lang.String command)
- Parameters:
name
- display name of the actioncommand
- the value of the action command key
-
TargetableAction
public TargetableAction(java.lang.String name, java.lang.String command, javax.swing.Icon icon)
- Parameters:
name
- display name of the actioncommand
- the value of the action command keyicon
- icon to display
-
TargetableAction
public TargetableAction(java.lang.String name, javax.swing.Icon icon)
-
-
Method Detail
-
setTargetManager
public void setTargetManager(TargetManager tm)
Set target manager which will handle this command. This action may be reset to use the singleton instance if set to null.- Parameters:
tm
- the target manager instance to dispatch the actions
-
getTargetManager
public TargetManager getTargetManager()
Returns the target manager instance which will be used for action dispatch. If the target manager has not previously been set then the singleton instance will be returned.- Returns:
- a non null target manager
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
Callback for command actions. This event will be redispatched to the target manager along with the value of the Action.ACTION_COMMAND_KEY- Parameters:
evt
- event which will be forwarded to the TargetManager- See Also:
TargetManager
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent evt)
Callback for toggle actions. This event will be redispatched to the target manager along with value of the the Action.ACTION_COMMAND_KEY- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
- Overrides:
itemStateChanged
in classAbstractActionExt
- Parameters:
evt
- event which will be forwarded to the TargetManager- See Also:
TargetManager
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractActionExt
-
-