CentOS 屏幕键盘未显示用于 Jawa Swing 文本输入字段 [英] CentOS On screen keyboard not showing for Jawa Swing Text entry fields

查看:50
本文介绍了CentOS 屏幕键盘未显示用于 Jawa Swing 文本输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个带有文本字段的 Java Swing 应用程序,它在没有物理键盘的触摸面板上运行在 CentOS 上.在 CentOS 中,在通用访问下,我们可以打开屏幕键盘,只要在任何应用程序上有文本输入,它就会出现.当我们使用终端或 GEdit 或类似应用程序时,这非常有效.但是当我们使用 Java Swing 应用程序时,操作系统似乎不明白有一个文本输入字段,也没有调出键盘.

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.

有一个选项可以让键盘始终打开,这不适合我们的应用程序,即使它解决了问题.当有文本输入时,键盘应该只在需要时出现.此外,Florence 等第三方键盘也无法满足客户的要求.

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.

有没有办法通过代码强制以编程方式在 CentOS 的屏幕键盘上调出 Caribou?(在 Ubuntu 16.04 中,可以通过调用命令onboard"来调出屏幕键盘Onboard")

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 :解决方案不必专门通过 Java.即使是命令或者shell脚本,我也可以用Java中的Processbuilder来调用.

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.

推荐答案

在 CentOS 7 (GNOME) 中,屏幕键盘作为一项名为Caribou"的服务运行.它侦听 dbus 消息以自动显示/隐藏.通过发送适当的 dbus 信号,我们可以强制显示/隐藏屏幕键盘.因此,当获得焦点(对于 Java Swing 控件)时,dbus 信号会在程序内部发送以显示/隐藏 CentOS 7 中的屏幕键盘.

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

还有一个用于发送 dbus 消息的 java 库.https://dbus.freedesktop.org/doc/dbus-java/dbus-java/

There is a java library also for sending dbus messages. https://dbus.freedesktop.org/doc/dbus-java/dbus-java/

但是在 CentOS 7.5 中似乎缺少 Caribou dbus 接口的 Show/Hide 接口

But the Show/Hide interface for Caribou dbus interface seems missing in CentOS 7.5

在 CentOS 7(KDE) 中,可以将键盘小部件添加到任务栏中,并且可以指定快捷方式来显示/隐藏屏幕键盘.从 java 程序可以模拟这个快捷键来显示/隐藏屏幕键盘.

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.

这篇关于CentOS 屏幕键盘未显示用于 Jawa Swing 文本输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆