com.wordpress.tipsforjava.swing
[Java] Class ActionMapAction
java.lang.Object
javax.swing.AbstractAction
com.wordpress.tipsforjava.swing.ActionMapAction
public class ActionMapAction
extends AbstractAction
The ActionMapAction class is a convenience class that allows you to use
an installed Action as an Action or ActionListener on a separate component.
It can be used on components like JButton or JMenuItem that support an
Action as a property of the component. Or it can be added to the same
above components as an ActionListener.
The benefit of this class is that a new ActionEvent will be created such
that the source of the event is the component the Action belongs to, not
the component that was "clicked". Otherwise in many cases a
ClassCastException will be thrown when the Action is invoked.
- Authors:
- Rob Camick
- Darryl Burke
|
Fields inherited from class AbstractAction
|
| DEFAULT, NAME, SHORT_DESCRIPTION, LONG_DESCRIPTION, SMALL_ICON, ACTION_COMMAND_KEY, ACCELERATOR_KEY, MNEMONIC_KEY, SELECTED_KEY, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY |
|
Methods inherited from class AbstractAction
|
| getValue, putValue, addPropertyChangeListener, isEnabled, setEnabled, removePropertyChangeListener, getPropertyChangeListeners, getKeys, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, actionPerformed |
actionCommand
private String actionCommand
-
component
private JComponent component
-
originalAction
private Action originalAction
-
ActionMapAction
public ActionMapAction(String name, JComponent component, String actionKey)
- Replace the default Action for the given KeyStroke with a custom Action
- Parameters:
name - the name parameter of the Actioncomponet - the component the Action belongs toactionKey - the key to identify the Action in the ActionMap
actionPerformed
public void actionPerformed(ActionEvent e)
- Invoke the original Action using the original component as the source
of the event.
setActionCommand
public void setActionCommand(String actionCommand)
-
Groovy Documentation