net.sourceforge.vietpad.inputmethod
Class VietKeyListener

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by net.sourceforge.vietpad.inputmethod.VietKeyListener
All Implemented Interfaces:
KeyListener, EventListener

public class VietKeyListener
extends KeyAdapter

Listener for Vietnamese key entries. Acts as an input preprocessor to VietKeyInput module, the keyboard engine.

A listener object created from this class, when registered with a text component using the component's addKeyListener method, gives the component the capability of Vietnamese text input. The class has numerous static methods to provide extra niceties to the registered text components. It includes support for shorthand, smart marking, and selection of popular Vietnamese input methods. A typical application is as follows:

     JTextComponent textComp = new JTextArea();
     VietKeyListener keyLst = new VietKeyListener(textComp);
     textComp.addKeyListener(keyLst);
     VietKeyListener.setInputMethod(InputMethods.Telex);
     VietKeyListener.setVietModeEnabled(true);
     VietKeyListener.setSmartMark(true);
 
A convenient JAR package is provided for easy integration to your program. A practical example can be found in VietPad, a full-featured Vietnamese Unicode text editor.


Constructor Summary
VietKeyListener(JComboBox comboBox)
          Creates a new VietKeyListener.
VietKeyListener(JTextComponent textComponent)
          Creates a new VietKeyListener.
 
Method Summary
static void consumeRepeatKey(boolean mode)
          Sets to consume the accent key when it is repeated to remove the diacritical mark just entered.
static InputMethods getInputMethod()
          Gets the current input method.
 void keyTyped(KeyEvent e)
          Invoked when a key has been typed.
static void setDiacriticsPosClassic(boolean classic)
          Sets the diacritics position to follow the classic style (òa, òe, úy), as opposed to the modern style (oà, oè, uý).
static void setInputMethod(InputMethods method)
          Sets the input method.
static void setMacroMap(Properties shortHandMap)
          Sets map for shorthand.
static void setSmartMark(boolean smartMark)
          Sets the SmartMark capability on or off.
static void setVietModeEnabled(boolean mode)
          Enables Vietnamese mode for key input.
 
Methods inherited from class java.awt.event.KeyAdapter
keyPressed, keyReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VietKeyListener

public VietKeyListener(JTextComponent textComponent)
Creates a new VietKeyListener.

Parameters:
textComponent - the JTextComponent to be listened

VietKeyListener

public VietKeyListener(JComboBox comboBox)
Creates a new VietKeyListener.

Parameters:
comboBox - the JComboBox to be listened
Method Detail

setVietModeEnabled

public static void setVietModeEnabled(boolean mode)
Enables Vietnamese mode for key input.

Parameters:
mode - true to enable entry of Vietnamese characters (enabled by default)

setInputMethod

public static void setInputMethod(InputMethods method)
Sets the input method.

Parameters:
method - one of the supported input methods: VNI, VIQR, or Telex (default)

getInputMethod

public static InputMethods getInputMethod()
Gets the current input method.

Returns:
the current input method

setSmartMark

public static void setSmartMark(boolean smartMark)
Sets the SmartMark capability on or off.

Parameters:
smartMark - true to enable automatic placement of diacritical marks on appropriate vowels in a word;
otherwise, they must be typed immediately after the character they qualify.

setDiacriticsPosClassic

public static void setDiacriticsPosClassic(boolean classic)
Sets the diacritics position to follow the classic style (òa, òe, úy), as opposed to the modern style (oà, oè, uý).

Parameters:
classic - true for classic; false for modern (default)

setMacroMap

public static void setMacroMap(Properties shortHandMap)
Sets map for shorthand.

Parameters:
shortHandMap - the list of shorthand sequences

keyTyped

public void keyTyped(KeyEvent e)
Invoked when a key has been typed.

Specified by:
keyTyped in interface KeyListener
Overrides:
keyTyped in class KeyAdapter
Parameters:
e - invoked when a key has been typed. This event occurs when a key press is followed by a key release.

consumeRepeatKey

public static void consumeRepeatKey(boolean mode)
Sets to consume the accent key when it is repeated to remove the diacritical mark just entered.

Parameters:
mode - true to consume the accent key when it is used to remove the diacritical mark just entered; false otherwise


Copyright © 2002 VietUnicode. All Rights Reserved.