I am working on developing an on-screen keyboard with java. This keyboard has a JComponent
for every possible key. When a mouse down is detected on the button
The only solution I could find so far, is to make every key a JComponent (so it can not have focus), and set the following properties on the JFrame:
setUndecorated(true);
setFocusableWindowState(false);
setFocusable(false);
enableInputMethods(false);
Now when using the robot class I can send events to any focused window by clicking on the keys. The only limitation, is that it only seems to work for windows that belong to the same virtual machine, and it doesn't work at all with any other system window.