javax.swing

Class AbstractAction

public abstract class AbstractAction extends Object implements Action, Cloneable, Serializable

A base class for implementing the {@link Action} interface.
Field Summary
protected SwingPropertyChangeSupportchangeSupport
Provides support for property change event notification.
protected booleanenabled
A flag that indicates whether or not the action is enabled.
Constructor Summary
AbstractAction()
Creates a new action with no properties set.
AbstractAction(String name)
Creates a new action with the specified name.
AbstractAction(String name, Icon icon)
Creates a new action with the specified name and icon.
Method Summary
voidaddPropertyChangeListener(PropertyChangeListener listener)
Registers a listener to receive {@link PropertyChangeEvent} notifications from this action.
protected Objectclone()
Returns a clone of the action.
protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)
Sends a {@link PropertyChangeEvent} for the named property to all registered listeners.
Object[]getKeys()
Returns an array of the keys for the property values that have been defined via the {@link #putValue(String, Object)} method (or the class constructor).
PropertyChangeListener[]getPropertyChangeListeners()
Returns all registered listeners.
ObjectgetValue(String key)
Returns the value associated with the specified key.
booleanisEnabled()
Returns the flag that indicates whether or not the 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 {@link PropertyChangeEvent} notifications from this action.
voidsetEnabled(boolean enabled)
Sets the flag that indicates whether or not the action is enabled and, if the value of the flag changed from the previous setting, sends a {@link java.beans.PropertyChangeEvent} to all registered listeners (using the property name 'enabled').

Field Detail

changeSupport

protected SwingPropertyChangeSupport changeSupport
Provides support for property change event notification.

enabled

protected boolean enabled
A flag that indicates whether or not the action is enabled.

Constructor Detail

AbstractAction

public AbstractAction()
Creates a new action with no properties set.

AbstractAction

public AbstractAction(String name)
Creates a new action with the specified name. The name is stored as a property with the key {@link Action#NAME}, and no other properties are initialised.

Parameters: name the name (null permitted).

AbstractAction

public AbstractAction(String name, Icon icon)
Creates a new action with the specified name and icon. The name is stored as a property with the key {@link Action#NAME}, the icon is stored as a property with the key {@link Action#SMALL_ICON}, and no other properties are initialised.

Parameters: name the name (null permitted). icon the icon (null permitted).

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers a listener to receive {@link PropertyChangeEvent} notifications from this action.

Parameters: listener the listener.

See Also: removePropertyChangeListener

clone

protected Object clone()
Returns a clone of the action.

Returns: A clone of the action.

Throws: CloneNotSupportedException if there is a problem cloning the action.

firePropertyChange

protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
Sends a {@link PropertyChangeEvent} for the named property to all registered listeners.

Parameters: propertyName the property name. oldValue the old value of the property. newValue the new value of the property.

getKeys

public Object[] getKeys()
Returns an array of the keys for the property values that have been defined via the {@link #putValue(String, Object)} method (or the class constructor).

Returns: An array of keys.

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns all registered listeners.

Returns: An array of listeners.

Since: 1.4

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.

See Also: AbstractAction

isEnabled

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

Returns: The flag.

See Also: AbstractAction

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: 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 {@link PropertyChangeEvent} notifications from this action.

Parameters: listener the listener.

See Also: addPropertyChangeListener

setEnabled

public void setEnabled(boolean enabled)
Sets the flag that indicates whether or not the action is enabled and, if the value of the flag changed from the previous setting, sends a {@link java.beans.PropertyChangeEvent} to all registered listeners (using the property name 'enabled').

Parameters: enabled the new flag value.

See Also: isEnabled