public abstract class AbstractAction extends Object implements Action, Cloneable, Serializable
Action
interface.Modifier and Type | Field and Description |
---|---|
protected SwingPropertyChangeSupport |
changeSupport
Provides support for property change event notification.
|
protected boolean |
enabled
A flag that indicates whether or not the action is enabled.
|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Registers a listener to receive
PropertyChangeEvent notifications
from this action. |
protected Object |
clone()
Returns a clone of the action.
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Sends a
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
putValue(String, Object) method (or the class
constructor). |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns all registered listeners.
|
Object |
getValue(String key)
Returns the value associated with the specified key.
|
boolean |
isEnabled()
Returns the flag that indicates whether or not the 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
PropertyChangeEvent notifications from this action. |
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
PropertyChangeEvent to all registered listeners (using
the property name 'enabled'). |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actionPerformed
protected boolean enabled
protected SwingPropertyChangeSupport changeSupport
public AbstractAction()
public AbstractAction(String name)
Action.NAME
, and no other properties are
initialised.name
- the name (null
permitted).public AbstractAction(String name, Icon icon)
Action.NAME
, the icon is stored as a
property with the key Action.SMALL_ICON
, and no other properties
are initialised.name
- the name (null
permitted).icon
- the icon (null
permitted).protected Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
- if there is a problem cloning the
action.Cloneable
public Object getValue(String key)
getValue
in interface Action
key
- the key (not null
).null
if the key is not found.putValue(String, Object)
public void putValue(String key, Object value)
PropertyChangeEvent
to all registered listeners.
The standard keys are:
Any existing value associated with the key will be overwritten.public boolean isEnabled()
isEnabled
in interface Action
setEnabled(boolean)
public void setEnabled(boolean enabled)
PropertyChangeEvent
to all registered listeners (using
the property name 'enabled').setEnabled
in interface Action
enabled
- the new flag value.isEnabled()
public Object[] getKeys()
putValue(String, Object)
method (or the class
constructor).protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
for the named property to all
registered listeners.propertyName
- the property name.oldValue
- the old value of the property.newValue
- the new value of the property.public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent
notifications
from this action.addPropertyChangeListener
in interface Action
listener
- the listener.removePropertyChangeListener(PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent
notifications from this action.removePropertyChangeListener
in interface Action
listener
- the listener.addPropertyChangeListener(PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()