In an Applet, I call .hasFocus() to figure out whether or not to hog the processor. I’d like something to tell me when my Frame is/isn’t being shown or has/doesn’t have focus so that I can manage this in my Applications too. I’ve had 0 luck with Google and the Java Almanac. I did find that LWJGL has something like Window.isDirty() and some other things. What options do I have for my Java2D game in a Frame?
Take a look at the WindowListener interface
public void windowActivated(WindowEvent e)
set active=true here
public void windowClosing(WindowEvent e)
set runloop=false here (for a clean exit)
public void windowDeactivated(WindowEvent e)
set active=false here