I'm developing a java application with some buttons, eventually I need to make a version for touch screen monitors. The problem I have right now is JTextFields are not opening an on-screen keyboard and also closing it is a problem.
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.
Code of JTextField not working:
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?
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");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.