echopointng
Class KeyStrokeListener

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by echopointng.ComponentEx
          extended by echopointng.KeyStrokeListener
All Implemented Interfaces:
Attributeable, java.io.Serializable, RenderIdSupport

public class KeyStrokeListener
extends ComponentEx

KeyStrokeListener is a component that listens for key stroke combinations and raises action events if any one of those key combinations have been pressed.

This can be a a single keystroke combination such as VK_F2 or a combination using a mask such as ALT_MASK | CONTROL_MASK | VK_F2 which is equates to Alt-Ctrl-F2.

Some components "EAT" all of the key strokes that go to them and hence only the key combinations that bubble up all the way to the base level will be able to be caught by the key stroke listener.

See Also:
Serialized Form

Field Summary
static java.lang.String ACTION_LISTENERS_CHANGED_PROPERTY
           
static int ALT_MASK
          Use this mask to determine if the ALT key is held a key is pressed
static int CONTROL_MASK
          Use this mask to determine if the CONTROL key is held a key is pressed
static java.lang.String KEYSTROKE_CHANGED_PROPERTY
           
static int META_MASK
          Use this mask to determine if the META key is held a key is pressed
static java.lang.String PROPERTY_CANCEL_MODE
           
static int SHIFT_MASK
          Use this mask to determine if the SHIFT key is held a key is pressed
static int VK_0
           
static int VK_1
           
static int VK_2
           
static int VK_3
           
static int VK_4
           
static int VK_5
           
static int VK_6
           
static int VK_7
           
static int VK_8
           
static int VK_9
           
static int VK_A
           
static int VK_ADD
           
static int VK_ALT
           
static int VK_B
           
static int VK_BACK_QUOTE
           
static int VK_BACK_SLASH
           
static int VK_BACK_SPACE
           
static int VK_C
           
static int VK_CANCEL
           
static int VK_CAPS_LOCK
           
static int VK_CLEAR
           
static int VK_CLOSE_BRACKET
           
static int VK_COMMA
           
static int VK_CONTEXT_MENU
           
static int VK_CONTROL
           
static int VK_D
           
static int VK_DECIMAL
           
static int VK_DELETE
           
static int VK_DIVIDE
           
static int VK_DOWN
           
static int VK_E
           
static int VK_END
           
static int VK_ENTER
           
static int VK_EQUALS
           
static int VK_ESCAPE
           
static int VK_F
           
static int VK_F1
           
static int VK_F10
           
static int VK_F11
           
static int VK_F12
           
static int VK_F13
           
static int VK_F14
           
static int VK_F15
           
static int VK_F16
           
static int VK_F17
           
static int VK_F18
           
static int VK_F19
           
static int VK_F2
           
static int VK_F20
           
static int VK_F21
           
static int VK_F22
           
static int VK_F23
           
static int VK_F24
           
static int VK_F3
           
static int VK_F4
           
static int VK_F5
           
static int VK_F6
           
static int VK_F7
           
static int VK_F8
           
static int VK_F9
           
static int VK_G
           
static int VK_H
           
static int VK_HELP
           
static int VK_HOME
           
static int VK_I
           
static int VK_INSERT
           
static int VK_J
           
static int VK_K
           
static int VK_L
           
static int VK_LEFT
           
static int VK_M
           
static int VK_META
           
static int VK_MULTIPLY
           
static int VK_N
           
static int VK_NUM_LOCK
           
static int VK_NUMPAD0
           
static int VK_NUMPAD1
           
static int VK_NUMPAD2
           
static int VK_NUMPAD3
           
static int VK_NUMPAD4
           
static int VK_NUMPAD5
           
static int VK_NUMPAD6
           
static int VK_NUMPAD7
           
static int VK_NUMPAD8
           
static int VK_NUMPAD9
           
static int VK_O
           
static int VK_OPEN_BRACKET
           
static int VK_P
           
static int VK_PAGE_DOWN
           
static int VK_PAGE_UP
           
static int VK_PAUSE
           
static int VK_PERIOD
           
static int VK_PRINTSCREEN
           
static int VK_Q
           
static int VK_QUOTE
           
static int VK_R
           
static int VK_RETURN
           
static int VK_RIGHT
           
static int VK_S
           
static int VK_SCROLL_LOCK
           
static int VK_SEMICOLON
           
static int VK_SEPARATOR
           
static int VK_SHIFT
           
static int VK_SLASH
           
static int VK_SPACE
           
static int VK_SUBTRACT
           
static int VK_T
           
static int VK_TAB
           
static int VK_U
           
static int VK_UP
           
static int VK_V
           
static int VK_W
           
static int VK_X
           
static int VK_Y
           
static int VK_Z
           
 
Fields inherited from class echopointng.ComponentEx
PROPERTY_HIDDEN
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
KeyStrokeListener()
          Constructs a KeyStrokeListener
 
Method Summary
 void addActionListener(ActionListener l)
          Adds an ActionListener to receive notification of user actions, i.e., key presses.
 void addKeyCombination(int keyCombination)
          This adds a key combination to the KeyStrokeListener using string returned from getMnemonic as the command string.
 void addKeyCombination(int keyCombination, java.lang.String command)
          This adds a key combination to the KeyStrokeListener.
 boolean getCancelMode()
           
 java.lang.String getKeyCombinationCommand(int keyCombination)
          Returns the command that is currently associated with the given key combination.
 int[] getKeyCombinations()
          Returns all the key combinations that currently in this KeyStrokeListener.
static java.lang.String getMnemonic(int keyCombination)
          This returns a mnemonic string representation of the given key combination for example 'F1' or 'Ctrl-F1' or 'A'.
 boolean hasActionListeners()
          Determines if there are any ActionListener s registered.
 boolean hasKeyCombination(int keyCombination)
          Returns true if the given key combination has been previously added to this KeyStrokeListener.
 boolean isValidChild(Component child)
          This component does not support children.
 void processInput(java.lang.String inputName, java.lang.Object inputValue)
          Processes client input specific to the Component received from the UpdateManager.
 void removeActionListener(ActionListener l)
          Removes an ActionListener from being notified of user actions, i.e., key presses.
 void removeKeyCombination(int keyCombination)
          Removes a key combination from this KeyStrokeListener.
 void setCancelMode(boolean newValue)
          When cancelMode is true, then the key stroke is cancel and prevented from bubling further up the hierarchy.
 
Methods inherited from class echopointng.ComponentEx
getAttribute, getAttributeNames, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, isHidden, setAttribute, setHidden, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALT_MASK

public static final int ALT_MASK
Use this mask to determine if the ALT key is held a key is pressed

See Also:
Constant Field Values

CONTROL_MASK

public static final int CONTROL_MASK
Use this mask to determine if the CONTROL key is held a key is pressed

See Also:
Constant Field Values

SHIFT_MASK

public static final int SHIFT_MASK
Use this mask to determine if the SHIFT key is held a key is pressed

See Also:
Constant Field Values

META_MASK

public static final int META_MASK
Use this mask to determine if the META key is held a key is pressed

See Also:
Constant Field Values

VK_CANCEL

public static final int VK_CANCEL
See Also:
Constant Field Values

VK_HELP

public static final int VK_HELP
See Also:
Constant Field Values

VK_BACK_SPACE

public static final int VK_BACK_SPACE
See Also:
Constant Field Values

VK_TAB

public static final int VK_TAB
See Also:
Constant Field Values

VK_CLEAR

public static final int VK_CLEAR
See Also:
Constant Field Values

VK_RETURN

public static final int VK_RETURN
See Also:
Constant Field Values

VK_ENTER

public static final int VK_ENTER
See Also:
Constant Field Values

VK_SHIFT

public static final int VK_SHIFT
See Also:
Constant Field Values

VK_CONTROL

public static final int VK_CONTROL
See Also:
Constant Field Values

VK_ALT

public static final int VK_ALT
See Also:
Constant Field Values

VK_PAUSE

public static final int VK_PAUSE
See Also:
Constant Field Values

VK_CAPS_LOCK

public static final int VK_CAPS_LOCK
See Also:
Constant Field Values

VK_ESCAPE

public static final int VK_ESCAPE
See Also:
Constant Field Values

VK_SPACE

public static final int VK_SPACE
See Also:
Constant Field Values

VK_PAGE_UP

public static final int VK_PAGE_UP
See Also:
Constant Field Values

VK_PAGE_DOWN

public static final int VK_PAGE_DOWN
See Also:
Constant Field Values

VK_END

public static final int VK_END
See Also:
Constant Field Values

VK_HOME

public static final int VK_HOME
See Also:
Constant Field Values

VK_LEFT

public static final int VK_LEFT
See Also:
Constant Field Values

VK_UP

public static final int VK_UP
See Also:
Constant Field Values

VK_RIGHT

public static final int VK_RIGHT
See Also:
Constant Field Values

VK_DOWN

public static final int VK_DOWN
See Also:
Constant Field Values

VK_PRINTSCREEN

public static final int VK_PRINTSCREEN
See Also:
Constant Field Values

VK_INSERT

public static final int VK_INSERT
See Also:
Constant Field Values

VK_DELETE

public static final int VK_DELETE
See Also:
Constant Field Values

VK_0

public static final int VK_0
See Also:
Constant Field Values

VK_1

public static final int VK_1
See Also:
Constant Field Values

VK_2

public static final int VK_2
See Also:
Constant Field Values

VK_3

public static final int VK_3
See Also:
Constant Field Values

VK_4

public static final int VK_4
See Also:
Constant Field Values

VK_5

public static final int VK_5
See Also:
Constant Field Values

VK_6

public static final int VK_6
See Also:
Constant Field Values

VK_7

public static final int VK_7
See Also:
Constant Field Values

VK_8

public static final int VK_8
See Also:
Constant Field Values

VK_9

public static final int VK_9
See Also:
Constant Field Values

VK_SEMICOLON

public static final int VK_SEMICOLON
See Also:
Constant Field Values

VK_EQUALS

public static final int VK_EQUALS
See Also:
Constant Field Values

VK_A

public static final int VK_A
See Also:
Constant Field Values

VK_B

public static final int VK_B
See Also:
Constant Field Values

VK_C

public static final int VK_C
See Also:
Constant Field Values

VK_D

public static final int VK_D
See Also:
Constant Field Values

VK_E

public static final int VK_E
See Also:
Constant Field Values

VK_F

public static final int VK_F
See Also:
Constant Field Values

VK_G

public static final int VK_G
See Also:
Constant Field Values

VK_H

public static final int VK_H
See Also:
Constant Field Values

VK_I

public static final int VK_I
See Also:
Constant Field Values

VK_J

public static final int VK_J
See Also:
Constant Field Values

VK_K

public static final int VK_K
See Also:
Constant Field Values

VK_L

public static final int VK_L
See Also:
Constant Field Values

VK_M

public static final int VK_M
See Also:
Constant Field Values

VK_N

public static final int VK_N
See Also:
Constant Field Values

VK_O

public static final int VK_O
See Also:
Constant Field Values

VK_P

public static final int VK_P
See Also:
Constant Field Values

VK_Q

public static final int VK_Q
See Also:
Constant Field Values

VK_R

public static final int VK_R
See Also:
Constant Field Values

VK_S

public static final int VK_S
See Also:
Constant Field Values

VK_T

public static final int VK_T
See Also:
Constant Field Values

VK_U

public static final int VK_U
See Also:
Constant Field Values

VK_V

public static final int VK_V
See Also:
Constant Field Values

VK_W

public static final int VK_W
See Also:
Constant Field Values

VK_X

public static final int VK_X
See Also:
Constant Field Values

VK_Y

public static final int VK_Y
See Also:
Constant Field Values

VK_Z

public static final int VK_Z
See Also:
Constant Field Values

VK_CONTEXT_MENU

public static final int VK_CONTEXT_MENU
See Also:
Constant Field Values

VK_NUMPAD0

public static final int VK_NUMPAD0
See Also:
Constant Field Values

VK_NUMPAD1

public static final int VK_NUMPAD1
See Also:
Constant Field Values

VK_NUMPAD2

public static final int VK_NUMPAD2
See Also:
Constant Field Values

VK_NUMPAD3

public static final int VK_NUMPAD3
See Also:
Constant Field Values

VK_NUMPAD4

public static final int VK_NUMPAD4
See Also:
Constant Field Values

VK_NUMPAD5

public static final int VK_NUMPAD5
See Also:
Constant Field Values

VK_NUMPAD6

public static final int VK_NUMPAD6
See Also:
Constant Field Values

VK_NUMPAD7

public static final int VK_NUMPAD7
See Also:
Constant Field Values

VK_NUMPAD8

public static final int VK_NUMPAD8
See Also:
Constant Field Values

VK_NUMPAD9

public static final int VK_NUMPAD9
See Also:
Constant Field Values

VK_MULTIPLY

public static final int VK_MULTIPLY
See Also:
Constant Field Values

VK_ADD

public static final int VK_ADD
See Also:
Constant Field Values

VK_SEPARATOR

public static final int VK_SEPARATOR
See Also:
Constant Field Values

VK_SUBTRACT

public static final int VK_SUBTRACT
See Also:
Constant Field Values

VK_DECIMAL

public static final int VK_DECIMAL
See Also:
Constant Field Values

VK_DIVIDE

public static final int VK_DIVIDE
See Also:
Constant Field Values

VK_F1

public static final int VK_F1
See Also:
Constant Field Values

VK_F2

public static final int VK_F2
See Also:
Constant Field Values

VK_F3

public static final int VK_F3
See Also:
Constant Field Values

VK_F4

public static final int VK_F4
See Also:
Constant Field Values

VK_F5

public static final int VK_F5
See Also:
Constant Field Values

VK_F6

public static final int VK_F6
See Also:
Constant Field Values

VK_F7

public static final int VK_F7
See Also:
Constant Field Values

VK_F8

public static final int VK_F8
See Also:
Constant Field Values

VK_F9

public static final int VK_F9
See Also:
Constant Field Values

VK_F10

public static final int VK_F10
See Also:
Constant Field Values

VK_F11

public static final int VK_F11
See Also:
Constant Field Values

VK_F12

public static final int VK_F12
See Also:
Constant Field Values

VK_F13

public static final int VK_F13
See Also:
Constant Field Values

VK_F14

public static final int VK_F14
See Also:
Constant Field Values

VK_F15

public static final int VK_F15
See Also:
Constant Field Values

VK_F16

public static final int VK_F16
See Also:
Constant Field Values

VK_F17

public static final int VK_F17
See Also:
Constant Field Values

VK_F18

public static final int VK_F18
See Also:
Constant Field Values

VK_F19

public static final int VK_F19
See Also:
Constant Field Values

VK_F20

public static final int VK_F20
See Also:
Constant Field Values

VK_F21

public static final int VK_F21
See Also:
Constant Field Values

VK_F22

public static final int VK_F22
See Also:
Constant Field Values

VK_F23

public static final int VK_F23
See Also:
Constant Field Values

VK_F24

public static final int VK_F24
See Also:
Constant Field Values

VK_NUM_LOCK

public static final int VK_NUM_LOCK
See Also:
Constant Field Values

VK_SCROLL_LOCK

public static final int VK_SCROLL_LOCK
See Also:
Constant Field Values

VK_COMMA

public static final int VK_COMMA
See Also:
Constant Field Values

VK_PERIOD

public static final int VK_PERIOD
See Also:
Constant Field Values

VK_SLASH

public static final int VK_SLASH
See Also:
Constant Field Values

VK_BACK_QUOTE

public static final int VK_BACK_QUOTE
See Also:
Constant Field Values

VK_OPEN_BRACKET

public static final int VK_OPEN_BRACKET
See Also:
Constant Field Values

VK_BACK_SLASH

public static final int VK_BACK_SLASH
See Also:
Constant Field Values

VK_CLOSE_BRACKET

public static final int VK_CLOSE_BRACKET
See Also:
Constant Field Values

VK_QUOTE

public static final int VK_QUOTE
See Also:
Constant Field Values

VK_META

public static final int VK_META
See Also:
Constant Field Values

ACTION_LISTENERS_CHANGED_PROPERTY

public static final java.lang.String ACTION_LISTENERS_CHANGED_PROPERTY
See Also:
Constant Field Values

KEYSTROKE_CHANGED_PROPERTY

public static final java.lang.String KEYSTROKE_CHANGED_PROPERTY
See Also:
Constant Field Values

PROPERTY_CANCEL_MODE

public static final java.lang.String PROPERTY_CANCEL_MODE
See Also:
Constant Field Values
Constructor Detail

KeyStrokeListener

public KeyStrokeListener()
Constructs a KeyStrokeListener

Method Detail

isValidChild

public boolean isValidChild(Component child)
This component does not support children.

Overrides:
isValidChild in class Component
Parameters:
child - the Component to evaluate as a child
Returns:
true if the Component is a valid child
See Also:
Component.isValidChild(nextapp.echo2.app.Component)

processInput

public void processInput(java.lang.String inputName,
                         java.lang.Object inputValue)
Description copied from class: Component
Processes client input specific to the Component received from the UpdateManager. Derivative implementations should take care to invoke super.processInput().

Overrides:
processInput in class Component
Parameters:
inputName - the name of the input
inputValue - the value of the input
See Also:
Component.processInput(java.lang.String, java.lang.Object)

addKeyCombination

public void addKeyCombination(int keyCombination,
                              java.lang.String command)
This adds a key combination to the KeyStrokeListener. This can be a single keystroke combination such as VK_F2 or a combination using a mask such as ALT_MASK | CONTROL_MASK | VK_F2 which is Alt-Ctrl-F2.

If this key combination is pressed, then the command will be used to raise an ActionEvent.

Parameters:
keyCombination - - the new key combination to add.
command - - the command to be used with the ActionEvent

addKeyCombination

public void addKeyCombination(int keyCombination)
This adds a key combination to the KeyStrokeListener using string returned from getMnemonic as the command string.

See Also:
addKeyCombination(int, String)

hasKeyCombination

public boolean hasKeyCombination(int keyCombination)
Returns true if the given key combination has been previously added to this KeyStrokeListener.

Parameters:
keyCombination - - the key combination to test for
Returns:
true if the given key combination has been previously added to this KeyStrokeListener.

removeKeyCombination

public void removeKeyCombination(int keyCombination)
Removes a key combination from this KeyStrokeListener.

Parameters:
keyCombination - - the key combination to remove.

getKeyCombinations

public int[] getKeyCombinations()
Returns all the key combinations that currently in this KeyStrokeListener.

Returns:
all the key combinations that currently in this KeyStrokeListener.

getKeyCombinationCommand

public java.lang.String getKeyCombinationCommand(int keyCombination)
Returns the command that is currently associated with the given key combination.

Parameters:
keyCombination - - the key combination to look for.
Returns:
the command that is currently associated with the given key combination.

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener to receive notification of user actions, i.e., key presses.

Parameters:
l - the listener to add

hasActionListeners

public boolean hasActionListeners()
Determines if there are any ActionListener s registered.

Returns:
true if any action listeners are registered

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener from being notified of user actions, i.e., key presses.

Parameters:
l - the listener to remove

getCancelMode

public boolean getCancelMode()
Returns:
true if cancel mode is currently in place.
See Also:
setCancelMode(boolean)

setCancelMode

public void setCancelMode(boolean newValue)
When cancelMode is true, then the key stroke is cancel and prevented from bubling further up the hierarchy. Not all key conbinations can be cancelled and not all user agents allow event cancelling at this level.

Parameters:
newValue - - the new cancel moed value

getMnemonic

public static java.lang.String getMnemonic(int keyCombination)
This returns a mnemonic string representation of the given key combination for example 'F1' or 'Ctrl-F1' or 'A'.

Parameters:
keyCombination - - the key combination to look for.
Returns:
returns a mnemonic string representation of the given key combination