Groovy Documentation

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


Field Summary
private String actionCommand

private JComponent component

private Action originalAction

 
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
 
Constructor Summary
ActionMapAction(String name, JComponent component, String actionKey)

Replace the default Action for the given KeyStroke with a custom Action

 
Method Summary
void actionPerformed(ActionEvent e)

Invoke the original Action using the original component as the source of the event.

void setActionCommand(String actionCommand)

 
Methods inherited from class AbstractAction
getValue, putValue, addPropertyChangeListener, isEnabled, setEnabled, removePropertyChangeListener, getPropertyChangeListeners, getKeys, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, actionPerformed
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

actionCommand

private String actionCommand


component

private JComponent component


originalAction

private Action originalAction


 
Constructor Detail

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 Action
componet - the component the Action belongs to
actionKey - the key to identify the Action in the ActionMap


 
Method Detail

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