Skip to main content
gamedev.net
🔒 Locked

Java swing drawing loop

Started by nullmind Feb 18, 2005 at 12:38 PM 0 replies 900+ views
Original Post
nullmind
nullmind
I am using a drawing loop inside my java swing application, I have decided there are multiple ways to exit my application and setup my render loop as so inside my class constructo (extending JFrame) while(!isClosed){ // game drawing and updating } dispose(); // we have exited the game, right? inside the windowClosed(WindowEvent e) event I have set this variable to false, as well as inside the keyPressed event that handles my input, with the VK_ESCAPE key. The drawing ends but the window remains after I have exited my drawing loop. Thanks, Kris
capn_midnight
capn_midnight
no, you have not exited the game after calling dispose, you have released any resources associated with the java.awt.Window (or a subclass of such) from which you called dispose.

link

Quote:

Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.

The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).


Use System.exit(0); to kill the program.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.