edu.northwestern.at.utils.swing
Class InputKeys

java.lang.Object
  extended by edu.northwestern.at.utils.swing.InputKeys

public class InputKeys
extends java.lang.Object

Methods for input key handling.


Constructor Summary
protected InputKeys()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static int getKeyEvent(java.lang.String keyName)
          Return KeyStroke for specified key character.
static void simulateKeyEvent(java.awt.event.KeyEvent keyEvent, java.awt.Component component)
          Simulate a key event for a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputKeys

protected InputKeys()
Don't allow instantiation but do allow overrides.

Method Detail

getKeyEvent

public static int getKeyEvent(java.lang.String keyName)
Return KeyStroke for specified key character.

Parameters:
keyName - The accelerator key name.
Returns:
The KeyEvent for this key name.

Only parly implemented!


simulateKeyEvent

public static void simulateKeyEvent(java.awt.event.KeyEvent keyEvent,
                                    java.awt.Component component)
                             throws java.lang.Exception
Simulate a key event for a component.

Parameters:
keyEvent - The key event.
component - The component to receive the event.
Throws:
java.lang.Exception - On any kind of exception.

A component will ignore events unless it appears to be focused. We set the the private field "focusManagerIsDispatching" in AWTEvent to true using reflection to allow the key event to take effect.