FileDocCategorySizeDatePackage
CommandAction.javaAPI DocExample2220Sat Jan 24 10:44:32 GMT 2004je3.gui

CommandAction

public class CommandAction extends AbstractAction

Fields Summary
Command
command
public static final String
ACCELERATOR_KEY
public static final String
MNEMONIC_KEY
Constructors Summary
public CommandAction(Command command, String label, Icon icon, String tooltip, KeyStroke accelerator, int mnemonic, boolean enabled)
Create an Action object that has the various specified attributes, and invokes the specified Command object in response to ActionEvents

	this.command = command;  // Remember the command to invoke
	
	// Set the various action attributes with putValue()
	if (label != null) putValue(NAME, label);
	if (icon != null) putValue(SMALL_ICON, icon);
	if (tooltip != null) putValue(SHORT_DESCRIPTION, tooltip);
	if (accelerator != null) putValue(ACCELERATOR_KEY, accelerator);
	if (mnemonic != KeyEvent.VK_UNDEFINED) 
	    putValue(MNEMONIC_KEY, new Integer(mnemonic));

	// Tell the action whether it is currently enabled or not
	setEnabled(enabled);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)
This method implements ActionListener, which is a super-interface of Action. When a component generates an ActionEvent, it is passed to this method. This method simply passes it on to the Command object which is also an ActionListener object

 command.actionPerformed(e);