Example usage for java.awt.event KeyEvent setKeyChar

List of usage examples for java.awt.event KeyEvent setKeyChar

Introduction

In this page you can find the example usage for java.awt.event KeyEvent setKeyChar.

Prototype

public void setKeyChar(char keyChar) 

Source Link

Document

Set the keyChar value to indicate a logical character.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_TYPED) {
                e.setKeyChar('a');
            }/*from  ww w.j  av a2s. c  o m*/
            boolean discardEvent = false;
            return discardEvent;
        }
    });
}