javax.swing

Interface Action

All Superinterfaces:
ActionListener, EventListener
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 Details

ACCELERATOR_KEY

public static final String ACCELERATOR_KEY
A key to access the KeyStroke used as the accelerator for the action.
Field Value:
"AcceleratorKey"

ACTION_COMMAND_KEY

public static final String ACTION_COMMAND_KEY
A key to access the action command string for the action.
Field Value:
"ActionCommandKey"

DEFAULT

public static final String DEFAULT
A key to access the default property for the action (this is not used).
Field Value:
"Default"

LONG_DESCRIPTION

public static final String LONG_DESCRIPTION
A key to access the long description for the action.
Field Value:
"LongDescription"

MNEMONIC_KEY

public static final String MNEMONIC_KEY
A key to access the mnemonic for the action.
Field Value:
"MnemonicKey"

NAME

public static final String NAME
A key to access the name for the action.
Field Value:
"Name"

SHORT_DESCRIPTION

public 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).
Field Value:
"ShortDescription"

SMALL_ICON

public static final String SMALL_ICON
A key to access the icon for the action.
Field Value:
"SmallIcon"

Method Details

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 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).

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 PropertyChangeEvent is sent to all registered listeners.
Parameters:
b - the new value of the flag.

Action.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.