1,105,585 Community Members

Dual JFrame Focus Thing

Member Avatar
turt2live
Junior Poster in Training
90 posts since Jan 2011
Reputation Points: 5 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello,

I currently have 2 JFrames for my "game" (Not really a good one), one for the actual game and one for a minimap.

What I can't figure out is that when you click off the game (for example to a browser or something) the game and minimap loose focus, but when you click on the game again, the minimap may not show or is still not on top.

What I want is so that once the game is brought into focus (they are playing the game) the minimap is shown next to it, on top.

I hope that makes sense.

Any help is appreciated.

-- Turt2Live

Member Avatar
mKorbel
Nearly a Posting Virtuoso
1,346 posts since Feb 2011
Reputation Points: 274 [?]
Q&As Helped to Solve: 277 [?]
Skill Endorsements: 14 [?]
 
0
 

standard is that you using just one JFrame and other TopLayoutContainers would be JDialog(s)

1/ it hard to manage Focus between two JFrames, nor to move one of then toFront() - sure its possible but code needed for that will be longer than your "game"

2/ JDialog#Modality - but chaning with JFrame Focus

3/ anyway is possible (search for that) set JFrame as parent for JDialog

Member Avatar
turt2live
Junior Poster in Training
90 posts since Jan 2011
Reputation Points: 5 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
1
 

Thank you very much :) I was trying to use a combination of WindowListners, Robots, and KeyEvents to hide the minimap, show it, then show the game.

Although I did learn that setting a JFrame to visible while it is already visible gives it focus :D

Question Answered as of 2 Years Ago by mKorbel
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: