java applet doesn't read all keys
I have a java applet that should read the keys the users presses in a website. I watch it in firefox on linux. It successfully ready all normal key and shows theirs ASCII vaule. But it can't dsiplay the special key like the "öäüöèéà" characters used in Europe and elsewhere (ISO-8859-1).
Here is the relevant code: Code:
public boolean keyDown(Event event, int j) But it seems that the special keys (öäüèé) don't activate this handler, because I watch the normal key's ASCII values, but nothing happens with the special key. So I guess they don't activate the keyDown... Is there an other method? How can I make it work for the special keys? |
Hi
Maybe i've misunderstood what you are saying, are you saying the accent keys do not trigger the keyDown event or that the accent keys trigger the method but don't generate an ascii value ? I use a UK keybard so i can't test the code, but could you tell me what happens when you press an accent key ? Code:
import javax.swing.*; http://java.sun.com/j2se/1.3/docs/ap...tml#getKeyCode() laters |
Thanks for your help!
The problem is that the accent key don't trigger the KeyDown event. I have no idea why and how to repair this. Is there a better version of KeyDown, that also reacts to accent keys? I compiled your code with javac, but can't run it with java, it says: Code:
nyk@homenyk nyk $ java keys.class |
Hi
When you run the code, you don't need the .class part Code:
java keys http://java.sun.com/docs/books/tutor...ylistener.html regards |
Thanx, I'll read this and try to make a key listener...
Now the codes for the accent chacter ö don't look good: Code:
� Key detected. ID = 400: Char �: KeyCode 0 Unknown keyCode: 0x0 |
I don't think my knowledge of java is good enough to write a key listener that accepts the accent keys!
From what I red on the web I got the impression that this might even be an impossible problem... Could it be that Sun just didn't implement support for European accent keys in their jre port to linux? Because if it's possible to create such a keylistener for the accent keys I find it strange that I can't find any traces of code that does such thing. I only found key-listeners posted in discussions about special keys (not neccessarily European accents) and all of them don't recognite the accent keys, they react to it but just report a symbol like this []. Does anyone know if this is possible to do and how or if it's not? |
Quote:
Java supports Unicode, and with it very exotic asian character set's, so there's no problem with good old european ones. Your problem is related to the environment you are running in, not Java. Just set and export the LC_ALL variable to the locale you want to support, say ch_DE or ch_FR and your program will display correctly the accented and other special characters. By default, your locale is "C", meaning only 7 bit ascii characters are recognized. |
This would be very nice, thanks!
But I tried these two ways and both of them failed! Code:
export LC_ALL=ch_DE Code:
LC_ALL=ch_DE firefox & But none of that works on gentoo or fedora code 3, you can't enter a accented key. The strange thing I figured out today is, that it works on my SuSe9 PC at work! How can this be? I think saw something in env containing UTF, but now when I login by ssh I don't see anything that could be usefull anymore... Do you have any idea what changes in env or configuration could result in this difference between the behaviour of SuSe and FC3/gentoo? |
Does it works with the standalone test program on FC / gentoo ?
Are you using the same JVMs on the three platforms ? |
Can't test it in standalone, it's an applet.
On the system that works, I use /usr/java/j2re1.4.2_03/plugin/i386/ns610-gcc32/libjavaplugin_oji.so as JVM. And on the system where it doesn't work this one: /opt/jre1.5.0_01/plugin/i386/ns7/libjavaplugin_oji.so But it's both the Sun version, which should work... |
I was referring to the standalone program send in this thread by darkroom.
Moreover, you can run an applet in standalone mode with appletviewer. |
Ok so im confused. A keyListener can't be written for the accent keys, but when said keys are used for normal input the correct symbol is written to stout ?
And why not change the locale in the actual program ? |
I don't know about a keylistener. It's not necessary, as the program works on SuSe, I would just like to know what could be the reason why it doesn't work in FC3 or gentoo....
|
Please test darkroom's standalone program as I already asked, or your applet with appletviewer, so we can have some clues about the issue.
|
All times are GMT -5. The time now is 08:16 PM. |