I have an Applet (AWT technology) running in Java Web Start. If the Web Start window closes, I need to perform some cleanup before the applet shuts down. Neither the overridden stop() nor the destroy() methods are executed. Any ideas how to force cleanup when Web Start is closed?
Implement the methods for the java.awt.event.WindowListener Interface and perform the cleanup somewhere in the windowClosing / windowClosed events. Leave those methods empty that you don't need.
Then find the top frame using something like
public Frame getFrame()
{
Container c = this;
while(c != null)
{
c = c.getParent();
if (c instanceof Frame)
{
appletFrame = (Frame)c;
break;
}
}
return appletFrame;
}
and add your window listener by appletFrame.addWindowListener(. . .);