Related question: Is there a way to access the thread that the applet is running? I could try killing the thread if there was someway.

12-26-2011, 02:13 PM

Norm

Re: Killing an applet inside a JPanel

Quote:

loaded an applet into a JPanel

Can you explain how you are executing the java program with the applet.
Is there a browser involved? How does the applet get to the AppletContext and AppletStub objects that are normally provided by a browser?
What GUI container is the JPanel loaded in?

Quote:

access the thread that the applet is running?

Which method(s) in the Applet are you talking about?

12-26-2011, 07:03 PM

John5788

Re: Killing an applet inside a JPanel

Hello,

I build everything the Applet needs to run and create my own AppletStub. The applet normally runs in a browser, but I am not using a browser to launch the applet inside my JPanel.

I setup my params in a hash map, then I download my JAR using a JarURLConnection. I finally create the applet by using JarURLConnection.loadClass().newInstance().

I'm not sure if this example is good enough to understand. But as I stated in my last post, I've discovered why my Swing GUI crashes, it is due to the Applet doing something bad that I cannot control. My solution is to try and run the applet in a new JVM to allow that to crash without disturbing the rest of my GUI. Now I need some ideas for this

12-27-2011, 12:47 AM

Norm

Re: Killing an applet inside a JPanel

Can you get the source for the applet and see what it is doing?

If you execute the applet in another JVM, what is the purpose of doing it? What results will you get from it?
You can always use the Runtime and Process classes to start another version of java.

12-27-2011, 12:50 AM

John5788

Re: Killing an applet inside a JPanel

Ah, maybe I should have included in my example that I am running the applet in a new thread.

Even in the new thread, when the applet crashes, it takes down the entire JVM unfortunately. Maybe there is no fix for this.

12-27-2011, 01:02 AM

Norm

Re: Killing an applet inside a JPanel

Look at the applet's source and see what it is doing.

12-27-2011, 04:48 PM

DarrylBurke

Re: Killing an applet inside a JPanel

Quote:

Originally Posted by John5788

The applet isnt owned by me. I am just creating a third party wrapper for the applet to add tools on top of the applet.

You could try to remove() the applet from the JPanel and add a new instance of it.

db

12-27-2011, 06:25 PM

camickr

Re: Killing an applet inside a JPanel

You have two methods. Which method stop() or destroy() is causing the problem? As I understand applets stop() is invoked when the browswer loses focus so in case you applet does animation you can pause the animation. Then destroy() would be used when the browswer window closes to release applet resources. If you are trying to use this in an application then I would guess you don't need to use this method.