0

I have a problem with getting focus to a JFrame after unhiding it, I am running OS X.

Specifically,

I am setting the DEFAUL_CLOSE_OPERATION to be HIDE_ON_CLOSE then I am using jnativehook library to get a global shortcut to unhide the application, the unhiding works just fine, but the problem is that the frame doesn't get the focus and I can't use it till I click on it by the mouse.

I have tried all of these methods :

setVisibel(true);
requestFocus();
toFront();
setEnabled(true);
requestFocusInWindow();
setExtendedState(JFrame.NORMAL);
setState(Frame.NORMAL);
setAutoRequestFocus(true);

Any help will be extremely appreciated.

iShaalan
  • 799
  • 2
  • 10
  • 30
  • focus came from Native OS, then set this parameter in jna code – mKorbel Sep 12 '14 at 07:37
  • @mKorbel I am not sure if I get that, Could you please give a further explanation, – iShaalan Sep 12 '14 at 07:44
  • I am assuming you have tested the focus request code and it works with a local shortcut? What does the hook callback look like? Are you sure you are operating on [Swing's Event Dispatching Thread](http://docs.oracle.com/javase/8/docs/api/javax/swing/SwingUtilities.html#isEventDispatchThread--)? If not we need more information, like a working example of the problem. – Alex Barker Sep 19 '14 at 23:01

0 Answers0