views:

272

answers:

1

I have a Swing Application running under Linux, that has problems to display accented characters.

Looking into the application, I tracked the problem to the Keyboard. I added a new EventQueueManager to intercept all events received.

I typed the "[dead acute] [a]" sequence on both systems.

In windows I get:

D 090116 100330.015000 AWT-EventQueue-1 [HotKeyManager.java : 133 - handleAWTEvent] java.awt.event.KeyEvent[KEY_PRESSED,keyCode=129,keyText=Dead Acute,keyChar='´',keyLocation=KEY_LOCATION_STANDARD] on frame0
D 090116 100330.109000 AWT-EventQueue-1 [HotKeyManager.java : 133 - handleAWTEvent] java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0
D 090116 100330.109000 AWT-EventQueue-1 [HotKeyManager.java : 133 - handleAWTEvent] java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='á',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
D 090116 100330.125000 AWT-EventQueue-1 [HotKeyManager.java : 133 - handleAWTEvent] java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar='´',keyLocation=KEY_LOCATION_STANDARD] on frame0
D 090116 100330.203000 AWT-EventQueue-1 [HotKeyManager.java : 133 - handleAWTEvent] java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0

Under Linux I get:

D 090116 151026.380000 AWT-EventQueue-0 [HotKeyManager.java : 132 - handleAWTEvent] java.awt.event.KeyEvent[KEY_RELEASED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='?',keyLocation=KEY_LOCATION_UNKNOWN] on frame0

So it seems that there is some difference in the way the keyboard is handled. Maybe some type of character encoding issue?

+1  A: 

I could be way off base, but I thought the dead keys worked by pressing and releasing the dead key, then pressing and releasing the target key - the windows events indicate you are using the dead key like a shift key, press and hold, hit target, release dead key.

Otherwise, I believe you have found a bug in either the JVM or the keyboard driver. One presumes that the dead key sequence works in native apps to produce an accented character, which would point the finger at Java. What JVM version? Is upgrading to a new JVM an option? Have you searched the sun website for bugs posted on this?

I do not believe this can be any kind of encoding problem - the key events are a different abstraction level that do not required encoding, per se. They produce virtual key codes and/or typeable Unicode characters (directly).

Software Monkey
It looks like it is a bug, or a mistmatch, between Java and the Hardware under linux, based on the used locales.
Mario Ortegón