APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public abstract Class AbstractAction

extends Object
implements Action, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, javax.swing.Action, java.awt.event.ActionListener, java.util.EventListener
Known Direct Subclasses
javax.swing.plaf.basic.BasicButtonUI.SelectPreviousBtn, javax.swing.plaf.basic.BasicButtonUI.SelectNextBtn, javax.swing.plaf.basic.BasicDesktopPaneUI.OpenAction, javax.swing.plaf.basic.BasicDesktopPaneUI.CloseAction, javax.swing.plaf.basic.BasicDesktopPaneUI.MinimizeAction, javax.swing.plaf.basic.BasicDesktopPaneUI.MaximizeAction, javax.swing.plaf.basic.BasicDesktopPaneUI.NavigateAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.CloseAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.IconifyAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.RestoreAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.MoveAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.ShowSystemMenuAction, javax.swing.plaf.basic.BasicInternalFrameTitlePane.SizeAction, javax.swing.plaf.basic.BasicLookAndFeel.AudioAction, javax.swing.plaf.basic.BasicSliderUI.ActionScroller, javax.swing.plaf.basic.BasicSliderUI.SharedActionScroller, javax.swing.plaf.basic.BasicSpinnerUI.ArrowButtonHandler, javax.swing.plaf.basic.BasicTextUI.FocusAction, javax.swing.plaf.basic.BasicTreeUI.TreeTraverseAction, javax.swing.plaf.basic.BasicTreeUI.TreePageAction, javax.swing.plaf.basic.BasicTreeUI.TreeIncrementAction, javax.swing.plaf.basic.BasicTreeUI.TreeHomeAction, javax.swing.plaf.basic.BasicTreeUI.TreeToggleAction, javax.swing.plaf.basic.BasicTreeUI.TreeCancelEditingAction, javax.swing.plaf.basic.BasicFileChooserUI.NewFolderAction, javax.swing.plaf.basic.BasicFileChooserUI.GoHomeAction, javax.swing.plaf.basic.BasicFileChooserUI.ChangeToParentDirectoryAction, javax.swing.plaf.basic.BasicFileChooserUI.ApproveSelectionAction, javax.swing.plaf.basic.BasicFileChooserUI.CancelSelectionAction, javax.swing.plaf.basic.BasicFileChooserUI.UpdateAction, javax.swing.plaf.metal.MetalFileChooserUI.DirectoryComboBoxAction, javax.swing.plaf.metal.MetalTitlePane.CloseAction, javax.swing.plaf.metal.MetalTitlePane.IconifyAction, javax.swing.plaf.metal.MetalTitlePane.RestoreAction, javax.swing.plaf.metal.MetalTitlePane.MaximizeAction, javax.swing.text.InternationalFormatter.IncrementAction, javax.swing.text.TextAction, sun.swing.FilePane.ViewTypeAction, com.sun.java.swing.plaf.gtk.GTKColorChooserPanel.ColorAction, com.sun.java.swing.plaf.gtk.GTKFileChooserUI.DirectoryComboBoxAction, com.sun.java.swing.plaf.gtk.GTKFileChooserUI.NewFolderAction, com.sun.java.swing.plaf.gtk.GTKFileChooserUI.RenameFileAction, sun.swing.plaf.synth.SynthFileChooserUI.FileNameCompletionAction, sun.swing.plaf.synth.SynthFileChooserUIImpl.DirectoryComboBoxAction
Annotations
@SuppressWarnings:serial
Imports
java.beans.PropertyChangeEvent, .PropertyChangeListener, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, javax.swing.event.SwingPropertyChangeSupport

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 JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Georges Saab
Since
1.2
See Also
Action

Field Summary

Modifier and TypeField and Description
private transient ArrayTable
arrayTable

Contains the array of key bindings.

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.

private static Boolean
RECONFIGURE_ON_NULL

Whether or not actions should reconfigure all properties on null.

Constructor Summary

AccessConstructor and Description
public
AbstractAction()

Creates an Action.

public
AbstractAction(String
the name (Action.NAME) for the action; a value of null is ignored
name
)

Creates an Action with the specified name.

public
AbstractAction(String
the name (Action.NAME) for the action; a value of null is ignored
name
,
Icon
the small icon (Action.SMALL_ICON) for the action; a value of null is ignored
icon
)

Creates an Action with the specified name and small icon.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addPropertyChangeListener(PropertyChangeListener
The PropertyChangeListener to be added
listener
)

Implements javax.swing.Action.addPropertyChangeListener.

Adds a PropertyChangeListener to the listener list.

protected Object
clone()

Overrides java.lang.Object.clone.

Clones the abstract action.

protected void
firePropertyChange(String
the name of the property that has changed
propertyName
,
Object
the old value of the property
oldValue
,
Object
the new value of the property
newValue
)

Supports reporting bound property changes.

public Object[]

Returns:

an array of key objects, or null if no keys have values set
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.

public synchronized PropertyChangeListener[]

Returns:

all of the PropertyChangeListeners added or an empty array if no listeners have been added
getPropertyChangeListeners
()

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

public Object

Returns:

the binding Object stored with this key; if there are no keys, it will return null
getValue
(String
a string containing the specified key
key
)

Implements javax.swing.Action.getValue.

Gets the Object associated with the specified key.

pack-priv static boolean
public boolean

Returns:

true if the action is enabled, false otherwise
isEnabled
()

Implements javax.swing.Action.isEnabled.

Returns true if the action is enabled.

pack-priv static boolean
public void
putValue(String
the String that identifies the stored object
key
,
Object
the Object to store using this key
newValue
)

Implements javax.swing.Action.putValue.

Sets the Value associated with the specified key.

private void
public synchronized void
removePropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be removed
listener
)

Implements javax.swing.Action.removePropertyChangeListener.

Removes a PropertyChangeListener from the listener list.

public void
setEnabled(boolean
true to enable the action, false to disable it
newValue
)

Implements javax.swing.Action.setEnabled.

Sets whether the Action is enabled.

pack-priv static void
setEnabledFromAction(JComponent
the Component to set the enabled state on
c
,
Action
the Action to set the enabled state from, may be null
a
)

Sets the enabled state of a component from an Action.

pack-priv static void
setToolTipTextFromAction(JComponent
the Component to set the tooltip text on
c
,
Action
the Action to set the tooltip text from, may be null
a
)

Sets the tooltip text of a component from an Action.

pack-priv static boolean
shouldReconfigure(PropertyChangeEvent e)

Whether or not to reconfigure all action properties from the specified event.

private void
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayTableback to summary
private transient ArrayTable arrayTable

Contains the array of key bindings.

changeSupportback to summary
protected SwingPropertyChangeSupport changeSupport

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

enabledback to summary
protected boolean enabled

Specifies whether action is enabled; the default is true.

RECONFIGURE_ON_NULLback to summary
private static Boolean RECONFIGURE_ON_NULL

Whether or not actions should reconfigure all properties on null.

Constructor Detail

AbstractActionback to summary
public AbstractAction()

Creates an Action.

AbstractActionback to summary
public AbstractAction(String name)

Creates an Action with the specified name.

Parameters
name:String

the name (Action.NAME) for the action; a value of null is ignored

AbstractActionback to summary
public AbstractAction(String name, Icon icon)

Creates an Action with the specified name and small icon.

Parameters
name:String

the name (Action.NAME) for the action; a value of null is ignored

icon:Icon

the small icon (Action.SMALL_ICON) for the action; a value of null is ignored

Method Detail

addPropertyChangeListenerback to summary
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)

Implements javax.swing.Action.addPropertyChangeListener.

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:PropertyChangeListener

The PropertyChangeListener to be added

See Also
Action#addPropertyChangeListener
cloneback to summary
protected Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

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().

Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

firePropertyChangeback to summary
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:String

the name of the property that has changed

oldValue:Object

the old value of the property

newValue:Object

the new value of the property

getKeysback to summary
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:Object[]

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

Since
1.3
getPropertyChangeListenersback to summary
public synchronized PropertyChangeListener[] getPropertyChangeListeners()

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

Returns:PropertyChangeListener[]

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

Since
1.4
getValueback to summary
public Object getValue(String key)

Implements javax.swing.Action.getValue.

Gets the Object associated with the specified key.

Parameters
key:String

a string containing the specified key

Returns:Object

the binding Object stored with this key; if there are no keys, it will return null

See Also
Action#getValue
hasSelectedKeyback to summary
pack-priv static boolean hasSelectedKey(Action a)
isEnabledback to summary
public boolean isEnabled()

Implements javax.swing.Action.isEnabled.

Returns true if the action is enabled.

Returns:boolean

true if the action is enabled, false otherwise

See Also
Action#isEnabled
isSelectedback to summary
pack-priv static boolean isSelected(Action a)
putValueback to summary
public void putValue(String key, Object newValue)

Implements javax.swing.Action.putValue.

Sets the Value associated with the specified key.

Parameters
key:String

the String that identifies the stored object

newValue:Object

the Object to store using this key

See Also
Action#putValue
readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
Annotations
@Serial
removePropertyChangeListenerback to summary
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)

Implements javax.swing.Action.removePropertyChangeListener.

Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters
listener:PropertyChangeListener

the PropertyChangeListener to be removed

See Also
Action#removePropertyChangeListener
setEnabledback to summary
public void setEnabled(boolean newValue)

Implements javax.swing.Action.setEnabled.

Sets whether the Action is enabled. The default is true.

Parameters
newValue:boolean

true to enable the action, false to disable it

See Also
Action#setEnabled
setEnabledFromActionback to summary
pack-priv static void setEnabledFromAction(JComponent c, Action a)

Sets the enabled state of a component from an Action.

Parameters
c:JComponent

the Component to set the enabled state on

a:Action

the Action to set the enabled state from, may be null

setToolTipTextFromActionback to summary
pack-priv static void setToolTipTextFromAction(JComponent c, Action a)

Sets the tooltip text of a component from an Action.

Parameters
c:JComponent

the Component to set the tooltip text on

a:Action

the Action to set the tooltip text from, may be null

shouldReconfigureback to summary
pack-priv static boolean shouldReconfigure(PropertyChangeEvent e)

Whether or not to reconfigure all action properties from the specified event.

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException
Annotations
@Serial