Other | Other |
---|---|
1.2.2_002 b02Fixed | 1.3.0Fixed |
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: diC59631 Date: 12/01/98 import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import com.sun.java.swing.JFrame; import com.sun.java.swing.JTextField; /** Modifiers (other than SHIFT) not delivered with KEY_TYPED. * * 1.2beta3 & 1.2beta4 * Solaris 2.6, BUT NOT WinNT * * In the Solaris environment, the ALT, CTRL, & META modifiers are * never set in a KEY_TYPED KeyEvent for a Lightweight component. * They are set in a WinNT environment. * * Consequently, ALT-a causes an "a" to be entered in the JTextField * (& similar components) in the Solaris environment, but not with WinNT. * Also, mnemonic and accelerator keystrokes are sometimes entered in these * Components because of this. Also, there are other platform * inconsistencies with KEY_TYPED when you combine modifiers. * * Note that the KeyEvent API doc, * http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/KeyEvent.html * and the "Writing a KeyListener" tutorial, * http://java.sun.com/docs/books/tutorial/ui/components/keylistener.html, * state that KEY_TYPED is used when a combination of characters maps to * a Unicode character. So it is unclear whether a KEY_TYPED should be * sent at all. (Since when does ALT-a map to Unicode "a"?) * * But at the very least, the Solaris behavior should change * to match WinNT so that Components and Listeners can easily * recognize normal character input. * * ###@###.### */ public class KeyEventDump implements KeyListener { public void keyPressed(KeyEvent e) { System.err.println(e); } public void keyTyped(KeyEvent e) { System.err.println(e); } public void keyReleased(KeyEvent e) { System.err.println(e); } public static void main(String args[]) { JTextField text = new JTextField(10); text.addKeyListener(new KeyEventDump()); JFrame frame = new JFrame(); frame.getContentPane().add(text); frame.pack(); frame.show(); } } (Review ID: 36497) ======================================================================
|