org.pietschy.command.delegate

Class SwingActionDelegate

Implemented Interfaces:
ActionCommandExecutor

public class SwingActionDelegate
extends CommandDelegate

SwingActionDelete is an instance of CommandDelegate that invokes an existing swing action. This is useful for mapping Commands to components that have built in actions.

Example.
CommandDelegate delgate = new SwingActionDelegate("copy-command", getActionMap(), "copy-to-clipboard")

The above example will invoke the "copy-to-clipboard" action when the "copy-command" is invoked.

Version:
$Revision: 1.2 $
Author:
andrewp

Field Summary

Fields inherited from class org.pietschy.command.delegate.CommandDelegate

PROPERTY_ENABLED

Constructor Summary

SwingActionDelegate(String id, Action action)
Creates a new delegate with the specified id that invokes the specfied javax.swing.Action.
SwingActionDelegate(String id, ActionMap actionMap, Object actionKey)
Creates a new delegate with the specified id that invokes the javax.swing.Action in the specified javax.swing.ActionMap with the specified action key.

Method Summary

void
execute(Map hints)

Methods inherited from class org.pietschy.command.delegate.CommandDelegate

addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getId, getPropertyChangeListeners, getPropertyChangeListeners, isEnabled, removePropertyChangeListener, removePropertyChangeListener, setEnabled

Constructor Details

SwingActionDelegate

public SwingActionDelegate(String id,
                           Action action)
Creates a new delegate with the specified id that invokes the specfied javax.swing.Action.
Parameters:
id - the id of the delegate.
action - the javax.swing.Action to invoke.

SwingActionDelegate

public SwingActionDelegate(String id,
                           ActionMap actionMap,
                           Object actionKey)
Creates a new delegate with the specified id that invokes the javax.swing.Action in the specified javax.swing.ActionMap with the specified action key.

Example.
CommandDelegate delgate = new SwingActionDelegate("copy-command", getActionMap(), "copy-to-clipboard")

The above example will invoke the "copy-to-clipboard" action when the "copy-command" is invoked.

Parameters:
id - the id of the delegate.
actionMap - the javax.swing.ActionMap containing the Action.
actionKey - the actions key within the map.

Method Details

execute

public void execute(Map hints)
Specified by:
execute in interface ActionCommandExecutor