OK... I have a problem with an applet that I am writing. The problem is that closing the browser does not kill the JRE/JVM.

When I started today, my applet had only an init() and a start(). init() contains the stuff to initialize all the components and create the applet UI. start() does nothing at the moment. I havent gotten that far. I want to get all the GUI stuff taken care of then write the rest of the applet code once I have all the buttons, checkboxes and listboxes created and actionlisteners created.

Using just init() and start(), I can complile and run the applet both in the applet viewer and in IE6 and Firefox. Killing the browser kills the applet and kills the JVM.

I decided that I wanted to add a closing dialog that was basically a cutsie littel thank you box.

I added the code to this to the stop() method as it is my understanding that that is the place for it to be, since that is called before the applet is destroyed.

After adding it there, however, if I kill the browser, an instance of the broswser stays running (seen in process list). THe JVM keeps running as well. I have to use the tast manager to kill the actual browser process to finally get the JVM and rogue browser instance to die completely.

What am I doing wrong here? Should I include something in the destroy() method to kill off everything? If so, what should that be? I have looked around, and while I can find all sorts of stuff in a general sense about stop() and destroy(), I cant find anything that sounds like the problem I am seeing.

Here are the console messages from running the applet:
Code:
//This is where I load the applet in the browser (Firefox in this case)
basic: Registered modality listener
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@1c86be5, refcount=1
basic: Added progress listener: sun.plugin.util.GreyBoxPainter@2bc49d
basic: Loading applet ...
basic: Initializing applet ...
basic: Starting applet ...

//Now that the applet is running, I close the browser window
basic: Stopping applet ...
basic: Removed progress listener: sun.plugin.util.GreyBox.Painter@2cb49d
basic: Joining applet thread ...
basic: Destroying applet ...
basic: Disposing applet ...
basic: Quiting applet ...
dialog starts here   // System.out.println to mark where the dialog opens
basic: Modality pushed
basic: Joined applet thread ...

//And the remaining messages occur once I click OK on the JOptionPane dialog:
basic: Modality popped
basic: Finding information ...
basic: Releasing classloader sun.plugin.ClassLoaderInfo@1c86be5, refcount=0
basic: Caching classloader: sun.plugin.ClassLoaderInfor@1c86be5
basic: Current classloader cache size: 1
basic: Done ...
At this point, I have loaded the applet in the browser, then closed the broswer, then closed the dialog by clicking OK.

It looks to me like, even though my JOptionPane is launched in stop() it is living well beyond the destroy() call. So my guess is that the JOptionPane is NOT a child of my applet, but is instead a different applet all together, that does not get destroyed.

Anyway, as I said, after clicking OK on the JOptionPane, the pane disappears but the browser process does not die, and thus the JVM does not die. I have tried putting the JOptionPane in the stop() method and the destroy() method but it looks as though once the Pane fires off, it becomes its own entity, and NOT a child of my applet.

So any suggestions? would using .setRootPane work to force it to be a child of the applet? or am I completely off base? Remeber, I am a newbie with Java...

Also, my code basically looks like this (with most of it stripped out for brevity):
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class MyApplet extends JApplet {
     public void init() {
          initialize stuff  //this part works fine
     }
     public void start() {
      // to be done soon
      }
     public void stop() {
         System.out.println("dialog starts here");
         JOptionPane.showMessageDialog(null."message contents", "title", JOptionPane.INFORMATION_MESSAGE);
      }
     public void destroy() {
     }
}
I just added an additional system message to both stop() and destroy() and it looks as though destroy is NOT called before the pane is finished... so now I am even more confused...

help?

Jeff