javax.swing

Interface Action

public interface Action extends ActionListener

Provides a convenient central point of control for some task that can be triggered by more than one control in a Swing user interface (for example, a menu item and a toolbar button).

See Also:

Field Summary
StringACCELERATOR_KEY
A key to access the {@link KeyStroke} used as the accelerator for the action.
StringACTION_COMMAND_KEY
A key to access the action command string for the action.
StringDEFAULT
A key to access the default property for the action (this is not used).
StringLONG_DESCRIPTION
A key to access the long description for the action.
StringMNEMONIC_KEY
A key to access the mnemonic for the action.
StringNAME
A key to access the name for the action.
StringSHORT_DESCRIPTION
A key to access the short description for the action (the short description is typically used as the tool tip text).
StringSMALL_ICON
A key to access the icon for the action.
Method Summary
voidaddPropertyChangeListener(PropertyChangeListener listener)
Registers a listener to receive notification whenever one of the action's properties is modified.
ObjectgetValue(String key)
Returns the value associated with the specified key.
booleanisEnabled()
Returns the flag that indicates whether or not this action is enabled.
voidputValue(String key, Object value)
Sets the value associated with the specified key and sends a {@link java.beans.PropertyChangeEvent} to all registered listeners.
voidremovePropertyChangeListener(PropertyChangeListener listener)
Deregisters a listener so that it no longer receives notification of changes to the action's properties.
voidsetEnabled(boolean b)
Sets the flag that indicates whether or not this action is enabled.

Field Detail

ACCELERATOR_KEY

public String ACCELERATOR_KEY
A key to access the {@link KeyStroke} used as the accelerator for the action.

ACTION_COMMAND_KEY

public String ACTION_COMMAND_KEY
A key to access the action command string for the action.

DEFAULT

public String DEFAULT
A key to access the default property for the action (this is not used).

LONG_DESCRIPTION

public String LONG_DESCRIPTION
A key to access the long description for the action.

MNEMONIC_KEY

public String MNEMONIC_KEY
A key to access the mnemonic for the action.

NAME

public String NAME
A key to access the name for the action.

SHORT_DESCRIPTION

public String SHORT_DESCRIPTION
A key to access the short description for the action (the short description is typically used as the tool tip text).

SMALL_ICON

public String SMALL_ICON
A key to access the icon for the action.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers a listener to receive notification whenever one of the action's properties is modified.

Parameters: listener the listener.

getValue

public Object getValue(String key)
Returns the value associated with the specified key.

Parameters: key the key (not null).

Returns: The value associated with the specified key, or null if the key is not found.

isEnabled

public boolean isEnabled()
Returns the flag that indicates whether or not this action is enabled.

Returns: The flag.

putValue

public void putValue(String key, Object value)
Sets the value associated with the specified key and sends a {@link java.beans.PropertyChangeEvent} to all registered listeners. The standard keys are defined in this interface: {@link #NAME}, {@link #SHORT_DESCRIPTION}, {@link #LONG_DESCRIPTION}, {@link #SMALL_ICON}, {@link #ACTION_COMMAND_KEY}, {@link #ACCELERATOR_KEY} and {@link #MNEMONIC_KEY}. Any existing value associated with the key will be overwritten.

Parameters: key the key (not null). value the value (null permitted).

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Deregisters a listener so that it no longer receives notification of changes to the action's properties.

Parameters: listener the listener.

setEnabled

public void setEnabled(boolean b)
Sets the flag that indicates whether or not this action is enabled. If the value changes, a {@link java.beans.PropertyChangeEvent} is sent to all registered listeners.

Parameters: b the new value of the flag.