Changing Keyboard Input language in Java

北慕城南 提交于 2019-12-11 06:09:44

问题


Is there a way to set/change the keyboard input language in Java (eg from English to German)?

Example Use Case: Script to be used for playback is recorded (typed in) on a German keyboard. The automated playback is done on a English keyboard...fails if keyboard is not set to German automatically before script is run.


回答1:


The keyboard input map is managed entirely by the operating system on every platform that I'm familiar with. Java provides no APIs for manipulating this in a cross-platform manner. I would investigate native APIs that you could manipulate via JNA, or even (if you're feeling dirty) shelling out to call some platform-specific command which does what you need.

You're not going to find a solution within the JDK standard lib.




回答2:


In java, you can use the InputContext class. See its API or do google search on InputContext.



来源:https://stackoverflow.com/questions/281466/changing-keyboard-input-language-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!