Duplicate :
|
|
Relates :
|
The fix for 4174399 fixed the problem for KEY_PRESSED and KEY_RELEASED events but not for KEY_TYPED events. At least the behaviour for KEY_TYPED events remains inconsistent on Solaris / win32. import java.awt.*; import java.awt.event.*; public class ModifierTest extends Frame implements KeyListener{ TextArea ta; public ModifierTest() { ta = new TextArea(8, 30); ta.addKeyListener(this); add(ta); pack(); show(); } public static void main(String[] args) { new ModifierTest(); } public void keyPressed(KeyEvent e) { System.out.println(e); } public void keyReleased(KeyEvent e) { System.out.println(e); } public void keyTyped(KeyEvent evt) { System.out.println(evt); } } Pressing Shift-A when the TextArea is in focus: $ uname -a SunOS ibm7 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-1 $ /usr/local/java/jdk1.1.8/solaris/bin/java -fullversion java full version "JDK1.1.8I" $ /usr/local/java/jdk1.1.8/solaris/bin/java ModifierTest java.awt.event.KeyEvent[KEY_PRESSED,keyCode=16,keyChar='',modifiers=Shift] on text0 java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyChar='A',modifiers=Shift] on text0 java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='A'] on text0 java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyChar='A',modifiers=Shift] on text0 java.awt.event.KeyEvent[KEY_RELEASED,keyCode=16,keyChar='',modifiers=Shift] on text0 On WinNT4.0 SP3: D:\KeyTest>\JDK1.1.8I-bin\jdk1.1.8\bin\java -fullversion java full version "JDK1.1.8I" D:\KeyTest>\JDK1.1.8I-bin\jdk1.1.8\bin\java ModifierTest java.awt.event.KeyEvent[KEY_PRESSED,keyCode=16,keyChar=' ',modifiers=Shift] on t ext0 java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyChar='A',modifiers=Shift] on t ext0 java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='A',modifiers=Shift] on text 0 java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyChar='A',modifiers=Shift] on text0 java.awt.event.KeyEvent[KEY_RELEASED,keyCode=16,keyChar=' '] on text0 The KEY_TYPED event includes modifiers=Shift for WinNT but not on Solaris. stuart.lawrence@eng 1999-03-09