Java swing difference between DISPOSE_ON_CLOSE and EXIT_ON_CLOSE

DISPOSE_ON_CLOSE (the default for JInternalFrame) :  Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.

EXIT_ON_CLOSE (defined in the JFrame class) : Exit the application, using System.exit(0). This is recommended for applications only. If used within an applet, a SecurityException may be thrown.

The recommendation is to use DISPOSE_ON_CLOSE. EXIT_ON_CLOSE abruptly ends the JVM which doesn’t give the application time to finish handling its tasks.

Other Response
DO_NOTHING_ON_CLOSE : Do not do anything when the user requests that the window close. Instead, the program should probably use a window listener that performs some other action in its windowClosing method.

HIDE_ON_CLOSE (the default for JDialog and JFrame) : Hide the window when the user closes it. This removes the window from the screen but leaves it displayable.

more info at http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html

  1. Thanks for this explanation.

Leave a Comment


*


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>