I’m not sure where to post this but I felt like it would fit here as my application is for older applet games to run in a similar environment
Basically, what I have is a “web browser” (https://github.com/andreja6/Internet-Adventure) who’s entire use is to run Java Applets (more specifically, older Java applet games that have never been ported, or simply just feel more nostalgic in the browser) since the new plugin is… well… horrific. Currently, I’m 100% stuck on trying to get the applets to stop and be disposed of whenever you navigate away from the page.
It loads the applets fine, but the applets NEVER STOP. I tried this:
for (int i = 0; i < comps.length; i++)
{
System.out.println(comps[i].getClass().getCanonicalName());
if (comps[i] instanceof JPanel)
for (Component a : ((JPanel) comps[i]).getComponents())
{
if (a instanceof Applet)
{
Applet app = (Applet) a;
app.stop();
app.destroy();
a = null;
app = null;
}
}
}
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
for(Thread t : threadSet)
{
try{t.interrupt();}catch(Throwable ex){};
}
and even if it works for a few, it doesn’t work for all, and I think try{t.interrupt();}catch(Throwable ex){}; really isn’t the best way to do this.
Is there any way to force stop the applet?
It starts the applet using AppletManager and a URLClassLoader
that part works perfectly fine, but when I navigate away and that code is called
it doesn’t dispose of the applet and still has it running in the background
Anybody have any suggestions?