public abstract class

UIAction

extends Object
implements Action
java.lang.Object
   ↳ sun.swing.UIAction

Class Overview

UIAction is the basis of all of basic's action classes that are used in an ActionMap. Subclasses need to override actionPerformed.

A typical subclass will look like:

    private static class Actions extends UIAction {
        Actions(String name) {
            super(name);
        }

        public void actionPerformed(ActionEvent ae) {
            if (getName() == "selectAll") {
                selectAll();
            }
            else if (getName() == "cancelEditing") {
                cancelEditing();
            }
        }
    }
 

Subclasses that wish to conditionalize the enabled state should override isEnabled(Component), and be aware that the passed in Component may be null.

See Also
  • com.sun.java.swing.ExtendedAction
  • Action

Summary

[Expand]
Inherited Constants
From interface javax.swing.Action
Public Constructors
UIAction(String name)
Public Methods
void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChange listener.
final String getName()
Object getValue(String key)
Gets one of this object's properties using the associated key.
boolean isEnabled(Object sender)
Subclasses that need to conditionalize the enabled state should override this.
final boolean isEnabled()
Cover method for isEnabled(null).
void putValue(String key, Object value)
Sets one of this object's properties using the associated key.
void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChange listener.
void setEnabled(boolean b)
Sets the enabled state of the Action.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.awt.event.ActionListener
From interface javax.swing.Action

Public Constructors

public UIAction (String name)

Public Methods

public void addPropertyChangeListener (PropertyChangeListener listener)

Adds a PropertyChange listener. Containers and attached components use these methods to register interest in this Action object. When its enabled state or other property changes, the registered listeners are informed of the change.

Parameters
listener a PropertyChangeListener object

public final String getName ()

public Object getValue (String key)

Gets one of this object's properties using the associated key.

public boolean isEnabled (Object sender)

Subclasses that need to conditionalize the enabled state should override this. Be aware that sender may be null.

Parameters
sender Widget enabled state is being asked for, may be null.

public final boolean isEnabled ()

Cover method for isEnabled(null).

Returns
  • true if this Action is enabled

public void putValue (String key, Object value)

Sets one of this object's properties using the associated key. If the value has changed, a PropertyChangeEvent is sent to listeners.

Parameters
key a String containing the key
value an Object value

public void removePropertyChangeListener (PropertyChangeListener listener)

Removes a PropertyChange listener.

Parameters
listener a PropertyChangeListener object

public void setEnabled (boolean b)

Sets the enabled state of the Action. When enabled, any component associated with this object is active and able to fire this object's actionPerformed method. If the value has changed, a PropertyChangeEvent is sent to listeners.

Parameters
b true to enable this Action, false to disable it