Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.jsxe.gui
Class KeyEventTranslator

    java.lang.Object
      net.sourceforge.jsxe.gui.KeyEventTranslator

public class KeyEventTranslator
extends Object

In conjunction with the `KeyEventWorkaround`, hides some warts in the AWT key event API.

Since:
  jsXe 0.5 pre1
Version:
  $Id: KeyEventTranslator.java,v 1.23 2004/07/12 19:25:07 spestov Exp $
Author:
  Slava Pestov, Ian Lewis (IanLewis@member.fsf.org)

Nested Class Summary
`static class` | `KeyEventTranslator.Key`

Constructor Summary
`KeyEventTranslator()`

Method Summary
`static void` | `addTranslation(KeyEventTranslator.Key key1, KeyEventTranslator.Key key2)` Adds a keyboard translation.
`static KeyStroke` | `getKeyStroke(String keyStroke)` Gets a Swing KeyStroke representing the internal key binding.
`static String` | `getModifierString(InputEvent evt)` Returns a string containing symbolic modifier names set in the specified event.
`static char` | `getSymbolicModifierName(int mod)` Returns a the symbolic modifier name for the specified Java modifier flag.
`static String` | `modifiersToString(int mods)`
`static KeyEventTranslator.Key` | `parseKey(String keyStroke)` Converts a string to a keystroke.
`static int` | `parseModifiers(String keyStroke)` Parses the keyStroke and returns the InputEvent modifiers
`static void` | `setModifierMapping(int c, int a, int m, int s)` Changes the mapping between symbolic modifier key names (`C`, `A`, `M`, `S`) and Java modifier flags.
`static KeyEventTranslator.Key` | `translateKeyEvent(KeyEvent evt)` Pass this an event from `KeyEventWorkaround.processKeyEvent(java.awt.event.KeyEvent)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### KeyEventTranslator

    public KeyEventTranslator()

Method Detail

### addTranslation

    public static void addTranslation(KeyEventTranslator.Key key1,
                                      KeyEventTranslator.Key key2)

  Adds a keyboard translation.

  Parameters:
    `key1` - Translate this key
    `key2` - Into this key

### translateKeyEvent

    public static KeyEventTranslator.Key translateKeyEvent(KeyEvent evt)

  Pass this an event from `KeyEventWorkaround.processKeyEvent(java.awt.event.KeyEvent)`.

### parseModifiers

    public static int parseModifiers(String keyStroke)

  Parses the keyStroke and returns the InputEvent modifiers

### parseKey

    public static KeyEventTranslator.Key parseKey(String keyStroke)

  Converts a string to a keystroke. The string should be of the form modifiers+shortcut where modifiers is any combination of A for Alt, C for Control, S for Shift or M for Meta, and shortcut is either a single character, or a keycode name from the `KeyEvent` class, without the `VK_` prefix.

  Parameters:
    `keyStroke` - A string description of the key stroke

### getKeyStroke

    public static KeyStroke getKeyStroke(String keyStroke)

  Gets a Swing KeyStroke representing the internal key binding.

### setModifierMapping

    public static void setModifierMapping(int c,
                                          int a,
                                          int m,
                                          int s)

  Changes the mapping between symbolic modifier key names (`C`, `A`, `M`, `S`) and Java modifier flags. You can map more than one Java modifier to a symobolic modifier, for example :

  ``

        setModifierMapping(
            InputEvent.CTRL_MASK,
            InputEvent.ALT_MASK | InputEvent.META_MASK,
            0,
            InputEvent.SHIFT_MASK);

       You cannot map a Java modifer to more than one symbolic modifier.

  Parameters:
    `c` - The modifier(s) to map the `C` modifier to
    `a` - The modifier(s) to map the `A` modifier to
    `m` - The modifier(s) to map the `M` modifier to
    `s` - The modifier(s) to map the `S` modifier to

### getSymbolicModifierName

    public static char getSymbolicModifierName(int mod)

  Returns a the symbolic modifier name for the specified Java modifier flag.

  Parameters:
    `mod` - A modifier constant from `InputEvent`

### modifiersToString

    public static String modifiersToString(int mods)

### getModifierString

    public static String getModifierString(InputEvent evt)

  Returns a string containing symbolic modifier names set in the specified event.

  Parameters:
    `evt` - The event

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD