Class: javax.swing.AbstractAction
- public abstract class AbstractAction
- implements Action, Cloneable, Serializable
This class provides default implementations for the JFC
Action
interface. Standard behaviors like the get and set methods for
Action object properties (icon, text, and enabled) are defined
here. The developer need only subclass this abstract class and
define the actionPerformed method.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see java.beans.XMLEncoder.
Methods
-
AbstractActiontop
public AbstractAction()Creates an Action. -
AbstractActiontop
public AbstractAction(String name)Creates an Action with the specified name. -
AbstractActiontop
Creates an Action with the specified name and small icon. -
addPropertyChangeListenertop
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)Adds aPropertyChangeListenerto the listener list. The listener is registered for all properties.A
PropertyChangeEventwill get fired in response to setting a bound property, e.g.setFont,setBackground, orsetForeground. Note that if the current component is inheriting its foreground, background, or font from its container, then no event will be fired in response to a change in the inherited property.- Specified by:
- addPropertyChangeListener from Action
-
clonetop
protected Object clone() throws CloneNotSupportedExceptionClones the abstract action. This gives the clone its own copy of the key/value list, which is not handled for you byObject.clone(). -
firePropertyChangetop
Supports reporting bound property changes. This method can be called when a bound property has changed and it will send the appropriatePropertyChangeEventto any registeredPropertyChangeListeners. -
getKeystop
public Object[] getKeys()Returns an array ofObjects which are keys for which values have been set for thisAbstractAction, ornullif no keys have values set. -
getPropertyChangeListenerstop
public synchronized PropertyChangeListener[] getPropertyChangeListeners()Returns an array of all thePropertyChangeListeners added to this AbstractAction with addPropertyChangeListener(). -
getValuetop
Gets theObjectassociated with the specified key. -
hasSelectedKeytop
static boolean hasSelectedKey(Action a) -
isEnabledtop
public boolean isEnabled()Returns true if the action is enabled. -
isSelectedtop
static boolean isSelected(Action a) -
putValuetop
Sets theValueassociated with the specified key. -
readObjecttop
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException -
removePropertyChangeListenertop
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)Removes aPropertyChangeListenerfrom the listener list. This removes aPropertyChangeListenerthat was registered for all properties.- Specified by:
- removePropertyChangeListener from Action
-
setEnabledtop
public void setEnabled(boolean newValue)Sets whether the Action is enabled. The default is true.- Specified by:
- setEnabled from Action
-
setEnabledFromActiontop
static void setEnabledFromAction(JComponent c, Action a)Sets the enabled state of a component from an Action. -
setToolTipTextFromActiontop
static void setToolTipTextFromAction(JComponent c, Action a)Sets the tooltip text of a component from an Action. -
shouldReconfiguretop
static boolean shouldReconfigure(PropertyChangeEvent e)Whether or not to reconfigure all action properties from the specified event. -
writeObjecttop
private void writeObject(ObjectOutputStream s) throws IOException
Fields
-
RECONFIGURE_ON_NULL
static private Boolean RECONFIGURE_ON_NULLWhether or not actions should reconfigure all properties on null. -
arrayTable
transient private ArrayTable arrayTableContains the array of key bindings. -
changeSupport
protected SwingPropertyChangeSupport changeSupportIf anyPropertyChangeListenershave been registered, thechangeSupportfield describes them. -
enabled
protected boolean enabledSpecifies whether action is enabled; the default is true.
