The second step in preparing an application
to respond to a click on a window's close button is to
connect a listener
instance to your application frame. That is, you connect, using
addWindowListener
, an instance of the listener defined in
Segment 685 to a frame such as the one introduced in
Segment 679:
import javax.swing.*;
public class Demonstrate {
public static void main (String argv []) {
JFrame frame = new JFrame("Movie Application");
frame.setSize(350, 150);
frame.addWindowListener(new ApplicationClosingWindowListener());
frame.show();
}
}