edu.neu.ccs.gui
Class KeyAction

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended byedu.neu.ccs.gui.KeyAction
All Implemented Interfaces:
Action, ActionListener, Cloneable, EventListener, Serializable

public abstract class KeyAction
extends AbstractAction

Encapsulates an action that is performed as a result of a KeyEvent.

Since:
1.0
Version:
2.2
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.AbstractAction
 
Field Summary
protected  int keyCodeOrChar
          The key code or character that triggers this action.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
KeyAction()
          Constructs a key action with no name or icon that is performed when any key is pressed, released, or typed.
KeyAction(int key)
          Constructs a key action with no name or icon that is performed when the given key is pressed, released, or typed.
KeyAction(int key, String name)
          Constructs a key action with the given name but no icon that is performed when the given key is pressed, released, or typed.
KeyAction(int key, String name, Icon icon)
          Constructs a key action with the given name and icon that is performed when the given key is pressed, released, or typed.
KeyAction(String name)
          Constructs a key action with the given name but no icon that is performed when any key is pressed, released, or typed.
KeyAction(String name, Icon icon)
          Constructs a key action with the given name and icon that is performed when any key is pressed, released, or typed.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Performs this action by calling the keyActionPerformed method of this class intended to perform tasks requiring information contained in the KeyEvent triggering this action.
abstract  void keyActionPerformed(KeyEvent kevt)
          Performs the tasks encapsulated by this action.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyCodeOrChar

protected int keyCodeOrChar
The key code or character that triggers this action.

Constructor Detail

KeyAction

public KeyAction()
Constructs a key action with no name or icon that is performed when any key is pressed, released, or typed.


KeyAction

public KeyAction(int key)
Constructs a key action with no name or icon that is performed when the given key is pressed, released, or typed.

Parameters:
key - the key code or character that triggers this action

KeyAction

public KeyAction(String name)
Constructs a key action with the given name but no icon that is performed when any key is pressed, released, or typed.

Parameters:
name - the name for this action

KeyAction

public KeyAction(int key,
                 String name)
Constructs a key action with the given name but no icon that is performed when the given key is pressed, released, or typed.

Parameters:
key - the key code or character that triggers this action
name - the name for this action

KeyAction

public KeyAction(String name,
                 Icon icon)
Constructs a key action with the given name and icon that is performed when any key is pressed, released, or typed.

Parameters:
name - the name for this action
icon - the icon for this action

KeyAction

public KeyAction(int key,
                 String name,
                 Icon icon)
Constructs a key action with the given name and icon that is performed when the given key is pressed, released, or typed.

Parameters:
key - the key code or character that triggers this action
name - the name for this action
icon - the icon for this action
Method Detail

actionPerformed

public final void actionPerformed(ActionEvent evt)
Performs this action by calling the keyActionPerformed method of this class intended to perform tasks requiring information contained in the KeyEvent triggering this action. If the given event is not a KeyActionEvent, this action is not performed.

Parameters:
evt - an object encapsulating an event that triggered this action

keyActionPerformed

public abstract void keyActionPerformed(KeyEvent kevt)
Performs the tasks encapsulated by this action. Subclasses should override this method to provide tasks this action performs.

Parameters:
kevt - the key event that triggered this action