This version of the CloseableFrame is a little more sophisticated than the version shown in class. In this version the listener class is made into an anonymous inner class of the frame.
The key piece of code is:
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
This innocent looking piece of code does a lot:
The syntax for the anonymous inner classes for event listeners takes some getting used to but pays off with very small and efficient generated code.
Example from CoreJava 1.1 vol 1 by Horstmann & Cornell