Applet does not restart

Started by Grandmaster B, August 19, 2008, 15:50:37

Previous topic - Next topic

Grandmaster B

Hi, i finally got my applet running. Problem is when i close the applet and rerun it again in the same instance of the browser the whole thing crashes (FF) or just doesn't work/start (IE).

This is basically the code im using to create the applet (setParent() method):
display_parent = new Canvas();
display_parent.setSize(780,480);
display_parent.setFocusable(true);
display_parent.setIgnoreRepaint(true);
applet.add(display_parent);
Display.setParent(display_parent);
Display.setVSyncEnabled(false);
Display.create();


I tried different things without luck. Any help is appreciated.

kappa

Remember you must destroy the display_parent when you finish with applet or want to restart. This will close the lwjgl display cleanly and prevent it crashing (and taking your browser out). This can be done with applets in destroy().

I'd recommend you look at how its done in the applet gears example

http://java-game-lib.svn.sourceforge.net/viewvc/java-game-lib/trunk/LWJGL/src/java/org/lwjgl/test/applet/GearsApplet.java?view=markup

Notice the slightly weird structure of the applet in that example, the main stuff is run in a seperate thread and display_parent is destroyed when that thread is done. This is done so that whatever happens in the new thread when the applet is closed/restarted display_parent will always be destroyed before it closes/restarts, thus avoiding a crash.

Grandmaster B