We have a Java swing application with text fields running on CentOS on a touch panel without physical keyboard. In CentOS, under universal access, we can switch on On Screen Keyboard which should come up whenever there is a text entry on any application. This works perfectly when we take the Terminal or GEdit or similar applications. But when we take the Java Swing application, The OS doesn't seem to understand there is a text entry field and doesn't bring up the keyboard.
There is an option to keep the Keyboard always open which is not suited in case of our application eventhough it solves the issue. The keyboard should come up only on demand when there is text entry. Also third party keyboards like Florence cannot be used to client requirements.
Is there a way to force to programatically bring up the Caribou on screen keyboard of CentOS through code? (In Ubuntu 16.04, it is possible to bring up the on-screen keyboard "Onboard" by calling command "onboard")
update : the solution need not be through Java specifically. Even if it is a command or shell script, I can use Processbuilder in Java to invoke it.
In CentOS 7 (GNOME), the on-screen keyboard runs as a service called "Caribou". It listens for dbus messages to auto-show/hide. By sending proper dbus signals, we can show/hide on-screen keyboard forcefully. So when getting focus (for Java Swing controls), the dbus signals were sent inside the program to show/hide the on-screen keyboard in CentOS 7.
These terminal commands can be tried to simulate this
dbus-send --type=method_call --dest=org.gnome.Caribou.Keyboard /org/gnome/Caribou/Keyboard org.gnome.Caribou.Keyboard.Show uint32:0
dbus-send --type=method_call --dest=org.gnome.Caribou.Keyboard /org/gnome/Caribou/Keyboard org.gnome.Caribou.Keyboard.Hide uint32:0
There is a java library also for sending dbus messages. https://dbus.freedesktop.org/doc/dbus-java/dbus-java/
But the Show/Hide interface for Caribou dbus interface seems missing in CentOS 7.5
In CentOS 7(KDE), keyboard widget is there which can be added to the task bar and shortcut can be assigned for showing/hiding the on-screen keyboard. From the java program this shortcut keys can be simulated to show/hide the on-screen keyboard.