public abstract class AbstractAction extends java.lang.Object implements Action, java.lang.Cloneable, java.io.Serializable
Action interface.| Modifier and Type | Field and Description |
|---|---|
protected javax.swing.event.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(java.lang.String name)
Creates a new action with the specified name.
|
AbstractAction(java.lang.String name,
Icon icon)
Creates a new action with the specified name and icon.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Registers a listener to receive
PropertyChangeEvent notifications
from this action. |
protected java.lang.Object |
clone()
Returns a clone of the action.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Sends a
PropertyChangeEvent for the named property to all
registered listeners. |
java.lang.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). |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
Returns all registered listeners.
|
java.lang.Object |
getValue(java.lang.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(java.lang.String key,
java.lang.Object value)
Sets the value associated with the specified key and sends a
PropertyChangeEvent to all registered listeners. |
void |
removePropertyChangeListener(java.beans.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'). |
protected boolean enabled
protected javax.swing.event.SwingPropertyChangeSupport changeSupport
public AbstractAction()
public AbstractAction(java.lang.String name)
Action.NAME, and no other properties are
initialised.name - the name (null permitted).public AbstractAction(java.lang.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 java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - if there is a problem cloning the
action.Cloneablepublic java.lang.Object getValue(java.lang.String key)
getValue in interface Actionkey - the key (not null).null if the key is not found.putValue(String, Object)public void putValue(java.lang.String key, java.lang.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 ActionsetEnabled(boolean)public void setEnabled(boolean enabled)
PropertyChangeEvent to all registered listeners (using
the property name 'enabled').setEnabled in interface Actionenabled - the new flag value.isEnabled()public java.lang.Object[] getKeys()
putValue(String, Object) method (or the class
constructor).protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.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(java.beans.PropertyChangeListener listener)
PropertyChangeEvent notifications
from this action.addPropertyChangeListener in interface Actionlistener - the listener.removePropertyChangeListener(PropertyChangeListener)public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeEvent notifications from this action.removePropertyChangeListener in interface Actionlistener - the listener.addPropertyChangeListener(PropertyChangeListener)public java.beans.PropertyChangeListener[] getPropertyChangeListeners()