Class AbstractActionExt
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.jdesktop.swingx.action.AbstractActionExt
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.awt.event.ItemListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action
- Direct Known Subclasses:
AbstractHyperlinkAction,BoundAction,ColumnControlButton.ColumnVisibilityAction,CompositeAction,TargetableAction
public abstract class AbstractActionExt extends javax.swing.AbstractAction implements java.awt.event.ItemListenerExtends the concept of the Action to include toggle or group states.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringGROUPThe key for the button groupstatic java.lang.StringIS_STATEThe key for the flag which indicates that this is a state type.static java.lang.StringLARGE_ICONThe key for the large icon
-
Constructor Summary
Constructors Constructor Description AbstractActionExt()Default constructor, does nothing.AbstractActionExt(java.lang.String name)AbstractActionExt(java.lang.String name, java.lang.String command)Constructs an Action with the label and commandAbstractActionExt(java.lang.String name, java.lang.String command, javax.swing.Icon icon)AbstractActionExt(java.lang.String name, javax.swing.Icon icon)AbstractActionExt(AbstractActionExt action)Copy constructor copies the state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Will perform cleanup on the object.javax.swing.KeyStrokegetAccelerator()Returns the key stroke which represents an accelerator for the action.java.lang.ObjectgetActionCommand()Returns the action command.java.lang.ObjectgetGroup()javax.swing.IcongetLargeIcon()Returns a large icon which represents the action.java.lang.StringgetLongDescription()Returns a long description of the action.intgetMnemonic()Return the mnemonic key code for the action.java.lang.StringgetName()Returns the name of the action.java.lang.StringgetShortDescription()Returns a short description of the action.javax.swing.IcongetSmallIcon()Returns a small icon which represents the action.booleanisSelected()booleanisStateAction()Indicates if this action has states.voiditemStateChanged(java.awt.event.ItemEvent e)Callback method asItemListener.voidsetAccelerator(javax.swing.KeyStroke key)Sets the key stroke which represents an accelerator for the action.voidsetActionCommand(java.lang.Object key)Sets the action command key.voidsetGroup(java.lang.Object group)Sets the group identity of the state action.voidsetLargeIcon(javax.swing.Icon icon)Sets the large icon which represents the action.voidsetLongDescription(java.lang.String desc)Sets the long description of the action.voidsetMnemonic(int mnemonic)Sets the mnemonic key code for the action.voidsetMnemonic(java.lang.String mnemonic)voidsetName(java.lang.String name)Sets the name of the action.voidsetSelected(boolean newValue)Changes the state of the actionvoidsetShortDescription(java.lang.String desc)Sets the short description of the action.voidsetSmallIcon(javax.swing.Icon icon)Sets the small icon which represents the action.voidsetStateAction()Set the state property to true.voidsetStateAction(boolean state)Set the state property.java.lang.StringtoString()-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
LARGE_ICON
public static final java.lang.String LARGE_ICON
The key for the large icon- See Also:
- Constant Field Values
-
GROUP
public static final java.lang.String GROUP
The key for the button group- See Also:
- Constant Field Values
-
IS_STATE
public static final java.lang.String IS_STATE
The key for the flag which indicates that this is a state type.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractActionExt
public AbstractActionExt()
Default constructor, does nothing.
-
AbstractActionExt
public AbstractActionExt(AbstractActionExt action)
Copy constructor copies the state.
-
AbstractActionExt
public AbstractActionExt(java.lang.String name)
-
AbstractActionExt
public AbstractActionExt(java.lang.String name, javax.swing.Icon icon)
-
AbstractActionExt
public AbstractActionExt(java.lang.String name, java.lang.String command)Constructs an Action with the label and command- Parameters:
name- name of the action usually used as a labelcommand- command key of the action
-
AbstractActionExt
public AbstractActionExt(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
-
getShortDescription
public java.lang.String getShortDescription()
Returns a short description of the action.- Returns:
- the short description or null
-
setShortDescription
public void setShortDescription(java.lang.String desc)
Sets the short description of the action. This will also set the long description value is it is null.This is a convenience method for
putValuewith theAction.SHORT_DESCRIPTIONkey.- Parameters:
desc- the short description; can benullw- See Also:
Action.SHORT_DESCRIPTION,Action.putValue(java.lang.String, java.lang.Object)
-
getLongDescription
public java.lang.String getLongDescription()
Returns a long description of the action.- Returns:
- the long description or null
-
setLongDescription
public void setLongDescription(java.lang.String desc)
Sets the long description of the action. This will also set the value of the short description if that value is null.This is a convenience method for
putValuewith theAction.LONG_DESCRIPTIONkey.- Parameters:
desc- the long description; can benull- See Also:
Action.LONG_DESCRIPTION,Action.putValue(java.lang.String, java.lang.Object)
-
getSmallIcon
public javax.swing.Icon getSmallIcon()
Returns a small icon which represents the action.- Returns:
- the small icon or null
-
setSmallIcon
public void setSmallIcon(javax.swing.Icon icon)
Sets the small icon which represents the action.This is a convenience method for
putValuewith theAction.SMALL_ICONkey.- Parameters:
icon- the small icon; can benull- See Also:
Action.SMALL_ICON,Action.putValue(java.lang.String, java.lang.Object)
-
getLargeIcon
public javax.swing.Icon getLargeIcon()
Returns a large icon which represents the action.- Returns:
- the large icon or null
-
setLargeIcon
public void setLargeIcon(javax.swing.Icon icon)
Sets the large icon which represents the action.This is a convenience method for
putValuewith theLARGE_ICONkey.- Parameters:
icon- the large icon; can benull- See Also:
LARGE_ICON,Action.putValue(java.lang.String, java.lang.Object)
-
setName
public void setName(java.lang.String name)
Sets the name of the action.This is a convenience method for
putValuewith theAction.NAMEkey.- Parameters:
name- the name of the action; can benull- See Also:
Action.NAME,Action.putValue(java.lang.String, java.lang.Object)
-
getName
public java.lang.String getName()
Returns the name of the action.- Returns:
- the name of the action or null
-
setMnemonic
public void setMnemonic(java.lang.String mnemonic)
-
setMnemonic
public void setMnemonic(int mnemonic)
Sets the mnemonic key code for the action.This is a convenience method for
putValuewith theAction.MNEMONIC_KEYkey.This method does not validate the value. Please see
AbstractButton.setMnemonic(int)for details concerning the value of the mnemonic.- Parameters:
mnemonic- an int key code mnemonic or 0- See Also:
AbstractButton.setMnemonic(int),Action.MNEMONIC_KEY,Action.putValue(java.lang.String, java.lang.Object)
-
getMnemonic
public int getMnemonic()
Return the mnemonic key code for the action.- Returns:
- the mnemonic or 0
-
setActionCommand
public void setActionCommand(java.lang.Object key)
Sets the action command key. The action command key is used to identify the action.This is a convenience method for
putValuewith theAction.ACTION_COMMAND_KEYkey.- Parameters:
key- the action command- See Also:
Action.ACTION_COMMAND_KEY,Action.putValue(java.lang.String, java.lang.Object)
-
getActionCommand
public java.lang.Object getActionCommand()
Returns the action command.- Returns:
- the action command or null
-
getAccelerator
public javax.swing.KeyStroke getAccelerator()
Returns the key stroke which represents an accelerator for the action.- Returns:
- the key stroke or null
-
setAccelerator
public void setAccelerator(javax.swing.KeyStroke key)
Sets the key stroke which represents an accelerator for the action.This is a convenience method for
putValuewith theAction.ACCELERATOR_KEYkey.- Parameters:
key- the key stroke; can benull- See Also:
Action.ACCELERATOR_KEY,Action.putValue(java.lang.String, java.lang.Object)
-
setGroup
public void setGroup(java.lang.Object group)
Sets the group identity of the state action. This is used to identify the action as part of a button group.
-
getGroup
public java.lang.Object getGroup()
-
dispose
public void dispose()
Will perform cleanup on the object. Should be called when finished with the Action. This should be used if a new action is constructed from the properties of an old action. The old action properties should be disposed.
-
isStateAction
public boolean isStateAction()
Indicates if this action has states. If this method returns true then the this will send ItemEvents to ItemListeners when the control constructed with this action in invoked.- Returns:
- true if this can handle states
-
setStateAction
public void setStateAction()
Set the state property to true.
-
setStateAction
public void setStateAction(boolean state)
Set the state property.- Parameters:
state- if true then this action will fire ItemEvents
-
isSelected
public boolean isSelected()
- Returns:
- true if the action is in the selected state
-
setSelected
public void setSelected(boolean newValue)
Changes the state of the action- Parameters:
newValue- true to set the action as selected of the action.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)
Callback method asItemListener. Updates internal state based on the given ItemEvent.Here: synchs selected property if isStateAction(), does nothing otherwise.
- Specified by:
itemStateChangedin interfacejava.awt.event.ItemListener- Parameters:
e- the ItemEvent fired by a ItemSelectable on changing the selected state.
-
-