I’m finnish man and letters Å, Ä and Ö (especially Ä and Ö) are necessary letters in some situations (if you cannot see these letters then you should probably change your browsers character encoding to something like western (ISO-8859-1)). These characters seem to be causing problems in my program which uses Robot class.
My programs idea is to read string from JTextField and write it to combobox letter by letter in my internet browser. This may sound bizarre idea but I didn’t find any other easy solution to highlight specific item in combobox than writing text in it. Anyway the reason why i need to do it isn’t important but I would like to know how I could avoid my program tilting when it gets nordic characters. Following code works if charAt(i) != å, ä or ö. But if charAt(i)==å,ä or ö then program fails and throws exceptions.
for(int i = 0; i < thisString.length();i++)
{
robot.keyPress(theString.charAt(i));
robot.keyRelease(theString.charAt(i));
}
Can I solve this problem somehow or is Robot class made only to american type of keyboard settings?
I got these exceptions:
Exception in thread “Thread-2” java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Robot.java:224)
at javaapplication3.JFrame.AI(JFrame.java:392)
at javaapplication3.JFrame.run(JFrame.java:427)
at java.lang.Thread.run(Thread.java:619)