|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
public abstract class AbstractAction
A base class for implementing the Action
interface.
Field Summary | |
---|---|
protected SwingPropertyChangeSupport |
changeSupport
Provides support for property change event notification. |
protected boolean |
enabled
A flag that indicates whether or not the action is enabled. |
Fields inherited from interface javax.swing.Action |
---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
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 | |
---|---|
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'). |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.ActionListener |
---|
actionPerformed |
Field Detail |
---|
protected boolean enabled
protected SwingPropertyChangeSupport changeSupport
Constructor Detail |
---|
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).Method Detail |
---|
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:
Action.NAME
Action.SHORT_DESCRIPTION
Action.LONG_DESCRIPTION
Action.SMALL_ICON
Action.ACTION_COMMAND_KEY
Action.ACCELERATOR_KEY
Action.MNEMONIC_KEY
putValue
in interface Action
key
- the key (not null
).value
- the value (null
permitted).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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |