JDK-4220772 : Key modifiers not passed for KEY_TYPED events on Solaris
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-03-16
  • Updated: 1999-04-06
  • Resolved: 1999-04-06
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The fix for 4174399 does not work for KEY_TYPED events and is considered only a partial fix.  The behaviour still remains inconsistent between Solaris and 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);
    }

}

E.g. press Shift-A when focus is inside the TextArea.
On Solaris:

$ 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

There are no modifiers for the KEY_TYPED event.  On WinNT (4.0 SP3) the following output is obtained:

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

This behaviour on NT is the same as 1.1.7B.

stuart.lawrence@eng 1999-03-16