Hi, users of the jdk1.1.6 v2-test libc5!
Please, can someone test the following code that listens to key-pressed
events.
Try the keys TAB and ENTER and look at the key char value:
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=9,Tab] on label0
KeyChar=65289
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=10,Enter] on label0
KeyChar=65293
^^^^^^^^^^^^^
wrong!
---------------------snip---KeyPrint.java------------------------------------
import java.awt.*;
import java.awt.event.*;
public class KeyPrint {
Frame f;
Label l;
class MyWindowAdapter extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
class MyKeyAdapter extends KeyAdapter {
public void keyPressed (KeyEvent e) {
int kco = e.getKeyCode();
int mods = e.getModifiers();
int kch = e.getKeyChar();
l.setText(e+" KeyChar="+kch);
}
}
public KeyPrint() {
f = new Frame("KeyPrint");
l = new Label();
l.addKeyListener(new MyKeyAdapter());
f.addWindowListener(new MyWindowAdapter());
f.add("Center", l);
f.setSize(600, 60);
f.setVisible(true);
}
public static void main ( String[] args ) {
KeyPrint kp = new KeyPrint();
}
}
---------------------snip---KeyPrint.java------------------------------------
Enjoy,
Juergen