There are a number of ways this could be implemented. Here when we see a Window.DESTROY event, we just hide the window. You could instead call dispose() to completely destroy the window and its contents. You might also wish to implement a scheme where the Window.DESTROY event gets passed to the applet. There's no easy way to do this. You'd probably need to use a different constructor to pass a reference to the applet into the closableWindow class, then call the applet's postEvent or deliverEvent methods to move the evnt from the window's event queue to the applet's event queue.
The source code