A good answer might be:

It should close the window.

WindowQuitter Class

The abstract windowing toolkit comes with a class called WindowAdapter. A WindowAdapter object is an event listener for window (ie. frame) events. To create a listener for a frame object do this:

  1. Create a listener object:
    • Extend WindowAdapter to create a child class for your special purpose.
    • Override each method in WindowAdapter for each type of event you want to respond to.
    • Use new to construct a listener object.
  2. Register the listener with the frame object:
    • Construct the frame object.
    • Use addWindowListener() to register the listener with the frame.
Registering a listener with a frame means connecting the two objects so that events from one object (the frame) are sent to the other (the listener.) This is not quite as bad as it seems. Here is a class definition that extends WindowAdapter.

public class WindowQuitter extends WindowAdapter
{
  public void windowClosing( WindowEvent e )
  {
    System.exit( 0 );  // what to do for this event
  }
}

The WindowAdapter class has many methods in it. To respond to window closing events, override the windowClosing() method. The Java system sends this method a WindowEvent object when the close window button is clicked.

A listener can respond to several types of events, but it must override the appropriate method for each type of event.

Your program can do whatever it needs to in response to the event. In WindowQuitter, we exit the entire program.

QUESTION 4:

Would a large application exit the entire program when a "close window" button is clicked?

Click Here after you have answered the question