[英]On-Screen Keyboard Java
I'm developing a java application with some buttons, eventually I need to make a version for touch screen monitors. 我正在开发带有一些按钮的Java应用程序,最终我需要为触摸屏显示器制作一个版本。 The problem I have right now is JTextFields are not opening an on-screen keyboard and also closing it is a problem.
我现在遇到的问题是JTextFields没有打开屏幕键盘,也没有关闭它。
If I use windows osk.exe, closing it as a process generates me some problems like it is not closing and also I don't have any control about it. 如果我使用Windows osk.exe,则将其作为进程关闭会产生一些问题,例如未关闭并且我对此也没有任何控制权。
Code of JTextField not working: JTextField的代码不起作用:
Gui.jtIdentification.addFocusListener(new FocusListener() {
Process proc;
@Override
public void focusGained(FocusEvent e) {
try {
proc = Runtime.getRuntime().exec("cmd /c C:\\Windows\\System32\\osk.exe");
} catch (IOException e1) {
e1.printStackTrace();
}
}
@Override
public void focusLost(FocusEvent e){
proc.destroy();
}
});
This piece of code is not functional. 这段代码不起作用。 How can I solve this?
我该如何解决? Any java library that makes it more easy and I can take control of it?
任何使它更简单并且可以控制的Java库?
Please Make the Process Object as static
请将过程对象设为静态
static Process proc;
public static void main(String[] args) throws IOException {
proc = Runtime.getRuntime().exec("cmd /c C:\\Windows\\System32\\osk.exe");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.