Well I used NetBeans and created a window with the GUI builder Desktop thing. It just freezes when you minimize it, and when you put it back in focus, it spams paint(..) for how many times paint(..) was missed while it was minimized.

euh when it's minimised paint isn't called because well frankly there shouldn't be anything to paint. Perhaps even the eventqueue polling is stopped too - would probably make sense. I'm not sure how you calculate the paint's being missed and if your using active rendering or not. If your using active rendering don't do it on the eventdispatcher thread. if your doing passive rendering - this is expected behaviour and your should do your logic in a separate thread.

Or it could be something else entirely - there's not much info to go by.

I have experienced similar problems with minimizing games even in commercial games. for example BF2142 will freeze if you minimize it. wich gya cauase sometime windows does a popup and minimizes the game .

you could make a window listener and have it listen for minimize and when that happens it loops and does Thread.sleep(however long you see fit) and then have it end when the window is not minimized anymore. this may be ironic cause it is fixing the pausing by pausing. but if you pause it will not expect to repaint so when it wont try and catch up on what it missed.

hope this helps . If you dont get what I mean jsut ask. I can go into further detail if you wish. Oh eyah and I am not sure if a window minimizing listener is possible. I know iwndow clossing is but....

I think I can show my solution best with my main loop. It will probably work for you too. I do, however, use active rendering. Repaint might conceivably still be called if you're using passive rendering, though I don't know why it would be.

Here's the code for my main loop:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

publicvoidexecute() {//verify that the loop will continueshouldContinueLoop = true;

This isApplicationActive method determines whether the application is "active". All it does is call Window.isActive() for the main Window of the game. The window is inactive when another application is selected and presumably also when the window is minimized.

Sleeping for half a second (or whatever amount of time you like) is necessary to prevent your program from taking up CPU cycles by checking whether the window is active constantly.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org