Java Reference
In-Depth Information
The windowClosing() method of your WindowListener is called when the user clicks the
close button (this depends on the window system and, on X Windows, on the window man-
ager) or sends the close message from the keyboard (normally Alt-F4).
The method signature is:
public void windowClosing(WindowEvent);
But this method comes from the interface WindowListener , which has half a dozen other
methods. If you define a WindowListener and implement only this one method, the com-
piler declares your class abstract and refuses to instantiate it. You might start by writing stub
or dummy versions (methods whose body is just the two characters {} ), but you'd then be
doing more work than necessary; an “adapter” class already does this for all methods in the
Listener interface. So you really need only to subclass from WindowAdapter and override
the one method, windowClosing , that you care about. Figure 14-5 shows this model.
Search WWH ::




Custom Search