Handling Window Events

Earlier it was mentioned that the constructor for FullScreenFrame1 calls the setWindowListener() method to ensure the program gets the closing, iconified, deiconified, activated, and deactivated events. In the FullScreenFrame1 class, the methods that handle these events were empty, except for the exitForm method. This method is called when the window-closing event is detected. The game window is removed from the screen, the video mode is restored, and the program exits. In FullScreenFrame2, code is introduced to handle the other events.

Basically, when the game’s window is deactivated or minimized, the rendering thread is paused so the player won’t get killed by the thousands of enemies that are constantly bearing down on him. When the window is reactivated or restored, the thread is unpaused so the player can continue the game.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net