United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7134826 [macosx] KeyEvent difference between Apple 1.6 and openjdk
7134826 : [macosx] KeyEvent difference between Apple 1.6 and openjdk

Details
Type:
Bug
Submit Date:
2012-01-27
Status:
Closed
Updated Date:
2012-09-25
Project Name:
JDK
Resolved Date:
2012-03-23
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7u4
Fixed Versions:
7u4

Related Reports

Sub Tasks

Description
http://java.net/jira/browse/MACOSX_PORT-568

Basically the code involved is a KeyListener on a JTextArea
setup like...
From the CmdJConsole class...
TextInterface theText = null, entry = null;

entry = new SwingTextArea("area","",2,80);
((Component)entry).addKeyListener(this);

[The entry component that the KeyListener ends up bolted to...
public class SwingTextAreaImpl extends JTextArea implements SwingTextImpl {

From the CmdJConsole KeyListener (keyTyped method) when CTRL-D is entered
With 1.7 I see this here...
CmdJConsole: byte 100 code 0
CmdJConsole: modifiers 128

With 1.6
CmdJConsole: byte 4 code 0
CmdJConsole: modifiers 128

The current workaround is...

byte keychar = (byte)kevt.getKeyChar();
if (keychar == (byte)4)
((CmdIn)imp.getIn()).eod();
else if (kevt.isControlDown() && kevt.getKeyChar() == 'd') { ((CmdIn)imp.getIn()).eod(); }
else...

The first 'if' works SE 6, the second works on SE 7.
I haven't come up with one that seems to cover both.

This is an old app I am getting up and running again. I plan on probably uploading shortly if a test case is wanted.
Or I can try to get a more isolated test case.

                                    

Comments
EVALUATION

The current fix doesn't work for layouts other then English (no matter what the current layout is, ctrl+D should always generate 0x04 character). Better fix is to rely on OS X to do the translation instead of doing it ourself in Java.
                                     
2012-01-27



Hardware and Software, Engineered to Work Together