javax.swing
Interface Action

All Superinterfaces:
ActionListener, EventListener
All Known Implementing Classes:
AbstractAction, BasicDesktopPaneUI.CloseAction, BasicDesktopPaneUI.MaximizeAction, BasicDesktopPaneUI.MinimizeAction, BasicDesktopPaneUI.NavigateAction, BasicDesktopPaneUI.OpenAction, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.UpdateAction, BasicInternalFrameTitlePane.CloseAction, BasicInternalFrameTitlePane.IconifyAction, BasicInternalFrameTitlePane.MaximizeAction, BasicInternalFrameTitlePane.MoveAction, BasicInternalFrameTitlePane.RestoreAction, BasicInternalFrameTitlePane.SizeAction, BasicSliderUI.ActionScroller, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreePageAction, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction, DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction, HTMLEditorKit.HTMLTextAction, HTMLEditorKit.InsertHTMLTextAction, MetalFileChooserUI.DirectoryComboBoxAction, StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.StyledTextAction, StyledEditorKit.UnderlineAction, TextAction

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:
AbstractButton.setAction(Action)

Field Summary
static String ACCELERATOR_KEY
          A key to access the KeyStroke used as the accelerator for the action.
static String ACTION_COMMAND_KEY
          A key to access the action command string for the action.
static String DEFAULT
          A key to access the default property for the action (this is not used).
static String LONG_DESCRIPTION
          A key to access the long description for the action.
static String MNEMONIC_KEY
          A key to access the mnemonic for the action.
static String NAME
          A key to access the name for the action.
static String SHORT_DESCRIPTION
          A key to access the short description for the action (the short description is typically used as the tool tip text).
static String SMALL_ICON
          A key to access the icon for the action.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers a listener to receive notification whenever one of the action's properties is modified.
 Object getValue(String key)
          Returns the value associated with the specified key.
 boolean isEnabled()
          Returns the flag that indicates whether or not this action is enabled.
 void putValue(String key, Object value)
          Sets the value associated with the specified key and sends a PropertyChangeEvent to all registered listeners.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Deregisters a listener so that it no longer receives notification of changes to the action's properties.
 void setEnabled(boolean b)
          Sets the flag that indicates whether or not this action is enabled.
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

DEFAULT

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

See Also:
Constant Field Values

LONG_DESCRIPTION

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

See Also:
Constant Field Values

NAME

static final String NAME
A key to access the name for the action.

See Also:
Constant Field Values

SHORT_DESCRIPTION

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

See Also:
Constant Field Values

SMALL_ICON

static final String SMALL_ICON
A key to access the icon for the action.

See Also:
Constant Field Values

ACCELERATOR_KEY

static final String ACCELERATOR_KEY
A key to access the KeyStroke used as the accelerator for the action.

See Also:
Constant Field Values

ACTION_COMMAND_KEY

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

See Also:
Constant Field Values

MNEMONIC_KEY

static final String MNEMONIC_KEY
A key to access the mnemonic for the action.

See Also:
Constant Field Values
Method Detail

getValue

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.

putValue

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

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

isEnabled

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

Returns:
The flag.

setEnabled

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

Parameters:
b - the new value of the flag.

addPropertyChangeListener

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

Parameters:
listener - the listener.

removePropertyChangeListener

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.