edu.neu.ccs.gui
Class KeyActionAdapter

java.lang.Object
  extended byedu.neu.ccs.gui.KeyActionAdapter
All Implemented Interfaces:
Cloneable, EventListener, KeyListener, Serializable

public class KeyActionAdapter
extends Object
implements KeyListener, Cloneable, Serializable

An adapter class for receiving key events, and performing action listeners in response to those events.

Since:
1.0
Version:
2.4.0
See Also:
Serialized Form

Field Summary
protected  ActionSequence pressedActions
          List of action listeners to be performed upon the notification of key pressed events.
protected  ActionSequence releasedActions
          List of action listeners to be performed upon the notification of key released events.
protected  ActionSequence typedActions
          List of action listeners to be performed upon the notification of key typed events.
 
Constructor Summary
KeyActionAdapter()
          Constructs a key action adapter.
KeyActionAdapter(Component target)
          Constructs a key action adapter listening for key events generated by the given component.
 
Method Summary
 void addKeyPressedAction(ActionListener a)
          Adds an action listener to this adapter so that it will be performed when a key is pressed.
 void addKeyReleasedAction(ActionListener a)
          Adds an action listener to this adapter so that it will be performed when a key is released.
 void addKeyTypedAction(ActionListener a)
          Adds an action listener to this adapter so that it will be performed when a key is typed.
 ActionSequence getKeyPressedActions()
          Returns the action sequence for key pressed events.
 ActionSequence getKeyReleasedActions()
          Returns the action sequence for key released events.
 ActionSequence getKeyTypedActions()
          Returns the action sequence for key typed events.
 void keyPressed(KeyEvent evt)
          Performs the stored action sequence when a key has been pressed.
 void keyReleased(KeyEvent evt)
          Performs the stored action sequence when a key has been released.
 void keyTyped(KeyEvent evt)
          Performs the stored action sequence when a key has been typed.
 void removeKeyPressedAction(ActionListener a)
          Removes the given action listener from this adapter so that it will be no longer be performed when a key is pressed.
 void removeKeyReleasedAction(ActionListener a)
          Removes the given action listener from this adapter so that it will be no longer be performed when a key is released.
 void removeKeyTypedAction(ActionListener a)
          Removes the given action listener from this adapter so that it will be no longer be performed when a key is typed.
 void setKeyPressedActions(ActionSequence sequence)
          Sets the action sequence for key pressed events to the provided action sequence.
 void setKeyReleasedActions(ActionSequence sequence)
          Sets the action sequence for key released events to the provided action sequence.
 void setKeyTypedActions(ActionSequence sequence)
          Sets the action sequence for key typed events to the provided action sequence.
 void uninstallAllKeyActions()
          Uninstall all key actions for this adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pressedActions

protected ActionSequence pressedActions
List of action listeners to be performed upon the notification of key pressed events.


releasedActions

protected ActionSequence releasedActions
List of action listeners to be performed upon the notification of key released events.


typedActions

protected ActionSequence typedActions
List of action listeners to be performed upon the notification of key typed events.

Constructor Detail

KeyActionAdapter

public KeyActionAdapter()
Constructs a key action adapter.


KeyActionAdapter

public KeyActionAdapter(Component target)
Constructs a key action adapter listening for key events generated by the given component. If null, this adapter does not listen to a particular component by default.

Parameters:
target - the component that is listened to
Method Detail

keyPressed

public final void keyPressed(KeyEvent evt)
Performs the stored action sequence when a key has been pressed.

Specified by:
keyPressed in interface KeyListener
Parameters:
evt - the key pressed event to be handled

keyReleased

public final void keyReleased(KeyEvent evt)
Performs the stored action sequence when a key has been released.

Specified by:
keyReleased in interface KeyListener
Parameters:
evt - the key released event to be handled

keyTyped

public final void keyTyped(KeyEvent evt)
Performs the stored action sequence when a key has been typed.

Specified by:
keyTyped in interface KeyListener
Parameters:
evt - the key typed event to be handled

addKeyPressedAction

public void addKeyPressedAction(ActionListener a)
Adds an action listener to this adapter so that it will be performed when a key is pressed.

Parameters:
a - the action listener to be performed
See Also:
removeKeyPressedAction(ActionListener), setKeyPressedActions(ActionSequence), getKeyPressedActions()

addKeyReleasedAction

public void addKeyReleasedAction(ActionListener a)
Adds an action listener to this adapter so that it will be performed when a key is released.

Parameters:
a - the action listener to be performed
See Also:
removeKeyReleasedAction(ActionListener), setKeyReleasedActions(ActionSequence), getKeyReleasedActions()

addKeyTypedAction

public void addKeyTypedAction(ActionListener a)
Adds an action listener to this adapter so that it will be performed when a key is typed.

Parameters:
a - the action listener to be performed
See Also:
removeKeyTypedAction(ActionListener), setKeyTypedActions(ActionSequence), getKeyTypedActions()

removeKeyPressedAction

public void removeKeyPressedAction(ActionListener a)
Removes the given action listener from this adapter so that it will be no longer be performed when a key is pressed.

Parameters:
a - the action listener to be removed
See Also:
addKeyPressedAction(ActionListener), setKeyPressedActions(ActionSequence), getKeyPressedActions()

removeKeyReleasedAction

public void removeKeyReleasedAction(ActionListener a)
Removes the given action listener from this adapter so that it will be no longer be performed when a key is released.

Parameters:
a - the action listener to be removed
See Also:
addKeyReleasedAction(ActionListener), setKeyReleasedActions(ActionSequence), getKeyReleasedActions()

removeKeyTypedAction

public void removeKeyTypedAction(ActionListener a)
Removes the given action listener from this adapter so that it will be no longer be performed when a key is typed.

Parameters:
a - the action listener to be removed
See Also:
addKeyTypedAction(ActionListener), setKeyTypedActions(ActionSequence), getKeyTypedActions()

setKeyPressedActions

public void setKeyPressedActions(ActionSequence sequence)
Sets the action sequence for key pressed events to the provided action sequence. If null, the action sequence for key pressed events is cleared.

Parameters:
sequence - the desired action sequence
See Also:
getKeyPressedActions(), addKeyPressedAction(ActionListener), removeKeyPressedAction(ActionListener)

setKeyReleasedActions

public void setKeyReleasedActions(ActionSequence sequence)
Sets the action sequence for key released events to the provided action sequence. If null, the action sequence for key released events is cleared.

Parameters:
sequence - the desired action sequence
See Also:
getKeyReleasedActions(), addKeyReleasedAction(ActionListener), removeKeyReleasedAction(ActionListener)

setKeyTypedActions

public void setKeyTypedActions(ActionSequence sequence)
Sets the action sequence for key typed events to the provided action sequence. If null, the action sequence for key typed events is cleared.

Parameters:
sequence - the desired action sequence
See Also:
getKeyTypedActions(), addKeyTypedAction(ActionListener), removeKeyTypedAction(ActionListener)

getKeyPressedActions

public ActionSequence getKeyPressedActions()
Returns the action sequence for key pressed events.

See Also:
setKeyPressedActions(ActionSequence), addKeyPressedAction(ActionListener), removeKeyPressedAction(ActionListener)

getKeyReleasedActions

public ActionSequence getKeyReleasedActions()
Returns the action sequence for key released events.

See Also:
setKeyReleasedActions(ActionSequence), addKeyReleasedAction(ActionListener), removeKeyReleasedAction(ActionListener)

getKeyTypedActions

public ActionSequence getKeyTypedActions()
Returns the action sequence for key typed events.

See Also:
setKeyTypedActions(ActionSequence), addKeyTypedAction(ActionListener), removeKeyTypedAction(ActionListener)

uninstallAllKeyActions

public void uninstallAllKeyActions()
Uninstall all key actions for this adapter.