Reputation: 329
there is a way of bringing my window to the front without minimizing the current Full Screen Game?
For example: I'm Playing a game and then i click CTRL+F and a window popup while I am in the game, and I can use that window and the game will not minimize or get out of focus.
I already have my code to myFrame.toFront(); myFrame.repaint();
when I click CTRL+F.
I appreciate if someone could help me, thanks
Carlos Barros
EDIT: Maybe I should have said this but the game is a game like Counter Strike or League of Legends I didn't make the game.
Upvotes: 2
Views: 404
Reputation: 324207
I already have my code to myFrame.toFront(); myFrame.repaint();
Don't use a JFrame as a popup window. An application should only have a single JFrame. For child windows you should use a JDialog. In your case it seems like you want a non-modal dialog.
and I can use that window and the game will not minimize or get out of focus.
When you display a dialog by default it will get focus whether it is modal or not (so the frame will lose focus).
If you want to prevent a non-modal dialog from getting initial focus then you need code like the following:
dialog.setFocusableWindowState( false );
dialog.setVisible(true);
dialog.setFocusableWindowState( true );
When you make the dialog visible it will not get focus (and the frame will retain focus). However, if you later click on the dialog it will be able to gain focus.
Upvotes: 2