How to detect Applet has been stopped or killed...
Hello,
I'm working on a Swing Applet that creates Annotations
I want to detect when the browser or Applet have been killed so that i can save the Annotation objects into XML format.
currently I have put the code to save the Annotations into XML format in the stop() method but this does not seem to be called. does this method get called automatically? or do I have to manually call it?
You may want to try using the destroy method rather than the stop method. Both stop and destroy are automatically called. Stop code is executed everytime the user leaves the page containing the applet, destroy is called when the browser exits. Java guarantees to call this method when the browser shuts down normally.
The problem is probably a security issue tho. Have you given the applet sufficent rights to write the annotations file to the location it has chosen?
And finally, if your not sure if the stop code is being executed why not make it pop up a dialog box or something to show that it's executing the code? It's more likely to be able to complete a dialog box command without error than file writing commands, ne?
Hope this helps.