writing virtual keyboard class.problem with involving diferent language.

I'm new in Java programing.

I'm making virtual keyboard class.I want to use it for any language.

For now it's work for my language (Croatian) if I involve in the button like:jButton26.setText("?);

or:jButton26.setText("\u0111");

In that case I could do it if I make class for any diferent language.

or using key code:

int code?=93; char char?=(char)code? String letter?= ""+char?

jButton?setText(letter?toLowerCase());

This way works for english letter but if I want involve for example Croatian language on the button this code don't work.

I use this method for getting value:

int keyCode = e.getKeyCode();

System.out.println("key code " + keyCode);

But this not work for Croatian.For Croatian letter I get value 0.

For example for ? key code 0

Please can you help me or sugest what is best way to resolve problem.

[916 byte] By [neckoa] at [2007-9-28 3:54:21]
# 1

I think you are making it more complicated than it have to be.

Java is by default I18N when it comes to the keyboard as long as the operation system can cater for it.

I am presuming in your case that you are having a keyboard listener to attach to get the keys. In the key event you can get the getKeyChar() which should give you the correct character depending on the settings of the OS. This might force you to shift to the keyTyped( ... ) method if you are currently using keyPress( ... ) but it should not pose a big problem.

Regards,

Peter Norell

bithira at 2007-7-7 23:26:31 > top of Java-index,Core,Core APIs...