Package org.jdesktop.swingx.action
Class BoundAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.jdesktop.swingx.action.AbstractActionExt
-
- org.jdesktop.swingx.action.BoundAction
-
- 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 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
BoundAction.BooleanInvocationHandler
The callback for the toggle/state changed action that invokes a method with a boolean argument on a target.
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.event.EventListenerList
listeners
private static java.util.logging.Logger
LOG
-
Fields inherited from class org.jdesktop.swingx.action.AbstractActionExt
GROUP, IS_STATE, LARGE_ICON
-
-
Constructor Summary
Constructors Constructor Description BoundAction()
BoundAction(java.lang.String name)
BoundAction(java.lang.String name, java.lang.String command)
BoundAction(java.lang.String name, java.lang.String command, javax.swing.Icon icon)
BoundAction(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.void
addActionListener(java.awt.event.ActionListener listener)
Add an action listener which will be invoked when this action is invoked.void
addItemListener(java.awt.event.ItemListener listener)
Add an item listener which will be invoked for toggle actions.private <T extends java.util.EventListener>
voidaddListener(java.lang.Class<T> clz, T listener)
java.awt.event.ActionListener[]
getActionListeners()
java.awt.event.ItemListener[]
getItemListeners()
private java.util.EventListener[]
getListeners(java.lang.Class<? extends java.util.EventListener> clz)
void
itemStateChanged(java.awt.event.ItemEvent evt)
Callback for toggle actions.private void
readObject(java.io.ObjectInputStream s)
void
registerCallback(java.lang.Object handler, java.lang.String method)
Registers a callback method when the Action corresponding to the action id is invoked.void
removeActionListener(java.awt.event.ActionListener listener)
void
removeItemListener(java.awt.event.ItemListener listener)
private <T extends java.util.EventListener>
voidremoveListener(java.lang.Class<T> clz, T listener)
void
setCallback(java.lang.String callback)
The callback string will be called to register the action callback.private void
writeObject(java.io.ObjectOutputStream s)
-
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
-
-
-
-
Constructor Detail
-
BoundAction
public BoundAction()
-
BoundAction
public BoundAction(java.lang.String name)
-
BoundAction
public BoundAction(java.lang.String name, java.lang.String command)
- Parameters:
name
- display name of the actioncommand
- the value of the action command key
-
BoundAction
public BoundAction(java.lang.String name, javax.swing.Icon icon)
-
BoundAction
public BoundAction(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
-
-
Method Detail
-
setCallback
public void setCallback(java.lang.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 registerregisterCallback(com.sun.foo.FubarHandler(), "handleBar");
-
registerCallback
public void registerCallback(java.lang.Object handler, java.lang.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 actionmethod
- the name of the method on the handler which will be called.
-
addListener
private <T extends java.util.EventListener> void addListener(java.lang.Class<T> clz, T listener)
-
removeListener
private <T extends java.util.EventListener> void removeListener(java.lang.Class<T> clz, T listener)
-
getListeners
private java.util.EventListener[] getListeners(java.lang.Class<? extends java.util.EventListener> clz)
-
addActionListener
public void addActionListener(java.awt.event.ActionListener listener)
Add an action listener which will be invoked when this action is invoked.
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener listener)
-
getActionListeners
public java.awt.event.ActionListener[] getActionListeners()
-
addItemListener
public void addItemListener(java.awt.event.ItemListener listener)
Add an item listener which will be invoked for toggle actions.
-
removeItemListener
public void removeItemListener(java.awt.event.ItemListener listener)
-
getItemListeners
public java.awt.event.ItemListener[] getItemListeners()
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
Callback for command actions.
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent evt)
Callback for toggle actions.- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
- Overrides:
itemStateChanged
in classAbstractActionExt
- Parameters:
evt
- the ItemEvent fired by a ItemSelectable on changing the selected state.
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.lang.ClassNotFoundException, java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
-
-