JFrame provides the setDefaultCloseOperation
method which can be used to configure the default action when a
JFrame is closed. For single framed applications it often the
case that closing the frame will exit the
application. Previously, developers had to add a WindowListener and
do this themselves. To make this common case easier for
developers to accomplish, a constant has been added to JFrame that
specifies when the frame closes the application should exit:
See: