net.sourceforge.vietpad
Class VietKeyListener

java.lang.Object
  extended byjava.awt.event.KeyAdapter
      extended bynet.sourceforge.vietpad.VietKeyListener
All Implemented Interfaces:
EventListener, KeyListener

public class VietKeyListener
extends KeyAdapter

Listener for Vietnamese key entries. Acts as an input preprocessor to VietKey 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); // default
     VietKeyListener.setVietModeEnabled(true); // default
     VietKeyListener.setSmartMark(true);
 
A convenient JAR package is provided for easy integration to your program. A practical example can be found in VietPad, a cross-platform Vietnamese 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.
static void setInputMethod(InputMethods method)
          Sets the input method.
static void setMacroMap(Properties shortHandMap)
          Sets map for shorthand.
static void setPaliSanskritModeEnabled(boolean mode)
          Sets Pali-Sanskrit/Dega mode for key input.
static void setSmartMark(boolean smartMark)
          Sets the SmartMark capability on or off.
static void setVietModeEnabled(boolean mode)
          Sets 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)
Sets Vietnamese mode for key input.

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

setPaliSanskritModeEnabled

public static void setPaliSanskritModeEnabled(boolean mode)
Sets Pali-Sanskrit/Dega mode for key input.

This capability is dependent on VIQR input method being selected.

Parameters:
mode - true to enable entry of Pali-Sanskrit/Dega characters in addition to Vietnamese

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.

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.

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