org.jdesktop.swingx
Class UIAction

java.lang.Object
  extended by org.jdesktop.swingx.UIAction
All Implemented Interfaces:
ActionListener, EventListener, Action

public abstract class UIAction
extends Object
implements Action

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.

This is based on sun.swing.UIAction in J2SE 1.5

See Also:
Action

Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
UIAction(String name)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChange listener.
 String getName()
           
 Object getValue(String key)
          Gets one of this object's properties using the associated key.
 boolean isEnabled()
          Cover method for isEnabled(null).
 boolean isEnabled(Object sender)
          Subclasses that need to conditionalize the enabled state should override this.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Constructor Detail

UIAction

public UIAction(String name)
Method Detail

getName

public final String getName()

getValue

public Object getValue(String key)
Description copied from interface: javax.swing.Action
Gets one of this object's properties using the associated key.

Specified by:
getValue in interface Action
See Also:
Action.putValue(java.lang.String, java.lang.Object)

putValue

public void putValue(String key,
                     Object value)
Description copied from interface: javax.swing.Action
Sets one of this object's properties using the associated key. If the value has changed, a PropertyChangeEvent is sent to listeners.

Specified by:
putValue in interface Action
Parameters:
key - a String containing the key
value - an Object value

setEnabled

public void setEnabled(boolean b)
Description copied from interface: javax.swing.Action
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.

Specified by:
setEnabled in interface Action
Parameters:
b - true to enable this Action, false to disable it

isEnabled

public final boolean isEnabled()
Cover method for isEnabled(null).

Specified by:
isEnabled in interface Action
Returns:
true if this Action is enabled

isEnabled

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.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: javax.swing.Action
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.

Specified by:
addPropertyChangeListener in interface Action
Parameters:
listener - a PropertyChangeListener object

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: javax.swing.Action
Removes a PropertyChange listener.

Specified by:
removePropertyChangeListener in interface Action
Parameters:
listener - a PropertyChangeListener object
See Also:
Action.addPropertyChangeListener(java.beans.PropertyChangeListener)