Change virtual keyboard to AZERTY

时光总嘲笑我的痴心妄想 提交于 2020-01-03 19:18:48

问题


I have a javafx application that is supposed to run in fullscreen mode on a Windows tablet.

My problem is, when the keyboard appears, it's in QWERTY whereas my tablet is in AZERTY.

So the question is : Is there a way to use the system virtual keyboard or to switch the javafx virtual keyboard to AZERTY?


回答1:


I found you question while trying to accopllish the same thing. I spent a day trying to make javafx display an AZERTY keyboard and i found a solution!

Well let me be clear : javafx gave no way at all to have an azerty keyboard so you have to hack a little.

The solution bellow is not a perfect one and you'll have to repeat it each time you update javafx, but it will allow you to extrem customize the keyboard far beyong querty and azerty.

SOLUTION 1 (dirty but works )

You will need to edit a file in javafx file shipped with the JDK

STEPS :

  1. GO to the JDK (in Mac : /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home)

  2. Go inside jre/lib/ext and copy javafx jar called jfxrt.jar to a folder on your desktop.

  3. Install EMACS if you don't have it and open the copied jar file with this software

  4. Browse files list searching for com/sun/javafx/scene/control/skin/TextBoard.txt the list is sorted from A-Z so use it (there is more than 6000 files).

  5. Open it and HERE you are. Change characters to whatever order makes you happy. I joined the azerty order.

  6. Save and copy back the jfxrt.jar to where it was. Done.

Note: don't try to extract the jar and rezip it, it won't work as jdk keeps an index list of files.

Result:azerty javafx virtual keyboard in action

SOLUTION 2 (Clean but i didn't finish it)

Whene i digged into javafx classes i found out that the class responsible for loading the TextBoard.txt file that lays out the keyboard is FXKVSkin This class is meant to receive other type of keyboards than the lonly qwerty default one. All you have to do is add this in your code :

textFieldThatYouUse.getProperties().put(FXVK.VK_TYPE_PROP_KEY, "mykeyboard");

Where mykeyboard is a file you created like TextBoard.txt called MykeyboardBoard.txt (capitals letters are important).

FXKVSkin will look now for a file called MykeyboardBoard.txt, and here's where my adventure ended. You will need to make FXKVSkin find your file, i tried by adding a file to the classpath at runtime solutions Here but it didn't work.

If anyone can solve this problem, please add it as an answer, it would be a less dirty solution.

Hope the solutions will help some non english speakers! :p




回答2:


The definition of the layout is contained in jfxrt.jar (part of the Java install). It is described by TextBoard.txt. It is possible to browse in the jfxrt.jar with 7zip or similar programs. TextBoard.txt is in com/sun/javafx/scene/control/skin/

This file is loaded com/sun/javafx/scene/control/skin/FXVKSkin.java is responsible for loading the TextBoard.txt file. Browse the javafx source (included via the jdk and contained in javafx-src.zip) to see how it is processed. Maybe this will give you enough information to load your own TextBoard.txt file.



来源:https://stackoverflow.com/questions/31335981/change-virtual-keyboard-to-azerty

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