I'm trying to develop something like a remote desktop / VNC client. It's necessary for me to capture all events in the client window. The method I'm using is to override the processEvent
method of the JFrame
:
@Override
protected void processEvent(AWTEvent e) {
...
}
However on events like the Windows
key or Alt+Tab
the window is getting deactivated:
...
00000191 KEY_PRESSED,keyCode=524,keyText=Windows,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=91,primaryLevelUnicode=0,scancode=91,extendedKeyCode=0x20c
00000192 KEY_RELEASED,keyCode=524,keyText=Windows,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=91,primaryLevelUnicode=0,scancode=91,extendedKeyCode=0x20c
000000ce WINDOW_DEACTIVATED,opposite=null,oldState=0,newState=0
...
How do I keep the window active on such events?
I would prefer a pure Java solution to this. If there is no pure java solution, can someone point me towards a JNA solution (or any other solution for that fact)?
EDIT1: * Resolved ambiguous term 'focus' to window deactivation * Emphasized that non pure Java solutions are acceptible