Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
To show that you can create a separate window from an applet (or from any other window, for that matter), we create an instance of our javax.swing.JFrame subclass .
We set its size, position it on the screen and make it visible :
We can use the same button on the applet to get rid of the window :
This gets rid of the visual counterpart,....
while this gets rid of our Java instance with its associated memory block, that will be garbage-collected.
When the window is closed, this code gets executed.
An anonymous instance of WindowAdapter ....
is registered as WindowListener, initially.
If you want to keep a window alive, use the same technique as with the dialog :
setVisible( false/true ) instead of dispose etc.
Always save a reference to the parent, the creator .