This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing
class AbstractAction

java.lang.Object extended by javax.swing.AbstractAction
All Implemented Interfaces:
Serializable, Cloneable, Action
Direct Known Subclasses:
BasicDesktopPaneUI.CloseAction, BasicDesktopPaneUI.MaximizeAction, BasicDesktopPaneUI.MinimizeAction, BasicDesktopPaneUI.NavigateAction, BasicDesktopPaneUI.OpenAction, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.UpdateAction, BasicInternalFrameTitlePane.CloseAction, BasicInternalFrameTitlePane.IconifyAction, BasicInternalFrameTitlePane.MaximizeAction, BasicInternalFrameTitlePane.MoveAction, BasicInternalFrameTitlePane.RestoreAction, BasicInternalFrameTitlePane.SizeAction, BasicSliderUI.ActionScroller, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreePageAction, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction, MetalFileChooserUI.DirectoryComboBoxAction, TextAction

public abstract class AbstractAction
extends Object
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 {@link java.beans.XMLEncoder}.


Field Summary
protected SwingPropertyChangeSupport changeSupport
          If any PropertyChangeListeners have been registered, the changeSupport field describes them.
protected boolean enabled
          Specifies whether action is enabled; the default is true.
 
Constructor Summary

          Defines an Action object with a default description string and default icon.

          Defines an Action object with the specified description string and a default icon.
AbstractAction(String name, Icon icon)

          Defines an Action object with the specified description string and a the specified icon.
 
Method Summary
 void

          Adds a PropertyChangeListener to the listener list.
protected Object

          Clones the abstract action.
protected void
firePropertyChange(String propertyName, Object oldValue, Object newValue)

          Supports reporting bound property changes.
 Object[]

          Returns an array of Objects which are keys for which values have been set for this AbstractAction, or null if no keys have values set.
 PropertyChangeListener[]

          Returns an array of all the PropertyChangeListeners added to this AbstractAction with addPropertyChangeListener().
 Object

          Gets the Object associated with the specified key.
 boolean

          Returns true if the action is enabled.
 void
putValue(String key, Object newValue)

          Sets the Value associated with the specified key.
 void

          Removes a PropertyChangeListener from the listener list.
 void
setEnabled(boolean newValue)

          Enables or disables the action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeSupport

protected SwingPropertyChangeSupport changeSupport
If any PropertyChangeListeners have been registered, the changeSupport field describes them.

enabled

protected boolean enabled
Specifies whether action is enabled; the default is true.
Constructor Detail

AbstractAction

public AbstractAction()
Defines an Action object with a default description string and default icon.


AbstractAction

public AbstractAction(String name)
Defines an Action object with the specified description string and a default icon.

Parameters:
name

AbstractAction

public AbstractAction(String name,
                      Icon icon)
Defines an Action object with the specified description string and a the specified icon.

Parameters:
name
icon
Method Detail

addPropertyChangeListener

public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired in response to setting a bound property, e.g. setFont, setBackground, or setForeground. 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.

Parameters:
listener - The PropertyChangeListener to be added

clone

protected Object clone()
                throws CloneNotSupportedException
Clones the abstract action. This gives the clone its own copy of the key/value list, which is not handled for you by Object.clone().

Overrides:
clone in class Object
Throws:
CloneNotSupportedException

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Supports reporting bound property changes. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName
oldValue
newValue

getKeys

public Object[] getKeys()
Returns an array of Objects which are keys for which values have been set for this AbstractAction, or null if no keys have values set.

Returns:
an array of key objects, or null if no keys have values set

getPropertyChangeListeners

public synchronized PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the PropertyChangeListeners added to this AbstractAction with addPropertyChangeListener().

Returns:
all of the PropertyChangeListeners added or an empty array if no listeners have been added

getValue

public Object getValue(String key)
Gets the Object associated with the specified key.

Parameters:
key - a string containing the specified key
Returns:
the binding Object stored with this key; if there are no keys, it will return null

isEnabled

public boolean isEnabled()
Returns true if the action is enabled.

Returns:
true if the action is enabled, false otherwise

putValue

public void putValue(String key,
                     Object newValue)
Sets the Value associated with the specified key.

Parameters:
key - the String that identifies the stored object
newValue - the Object to store using this key

removePropertyChangeListener

public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - the PropertyChangeListener to be removed

setEnabled

public void setEnabled(boolean newValue)
Enables or disables the action.

Parameters:
newValue - true to enable the action, false to disable it


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.