deploying non-jogl files with JNLPAppletLauncher

I have an applet which calls GLCanvas only in some of the cases as a popup window. Actually most of the GUI was built by Netbeans IDE. I’m getting the following error, I’m not sure what the exact reason is.


JNLPAppletLauncher: static initializer
os.name = windows xp
nativePrefix =   nativeSuffix = .dll
tmpRootDir = C:\DOCUME~1\RONEGL~1\LOCALS~1\Temp\jnlp-applet\jln34201
Applet.init
subapplet.classname = pCSDT.GUI
subapplet.displayname = PCSDT Applet
Applet.start
os.name = windows xp
os.arch = x86
processNativeJar: using previously cached: C:\Documents and Settings\Ron Eglash\.jnlp-applet\cache\www_cs_rpi_edu\be9cbf375512b1e82b6f965bac3ef0a30b1d6b78\jogl-natives-windows-i586.jar
validateCertificates:
VALIDATE: jogl.dll
VALIDATE: jogl_awt.dll
VALIDATE: jogl_cg.dll
extractNativeLibs:
EXTRACT: jogl.dll(jogl)
EXTRACT: jogl_awt.dll(jogl_awt)
EXTRACT: jogl_cg.dll(jogl_cg)
processNativeJar: using previously cached: C:\Documents and Settings\Ron Eglash\.jnlp-applet\cache\www_cs_rpi_edu\be9cbf375512b1e82b6f965bac3ef0a30b1d6b78\gluegen-rt-natives-windows-i586.jar
validateCertificates:
VALIDATE: gluegen-rt.dll
extractNativeLibs:
EXTRACT: gluegen-rt.dll(gluegen-rt)
Exception in thread "AWT-EventQueue-2" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
	at java.awt.EventQueue.invokeAndWait(Unknown Source)
	at pCSDT.GUI.init(GUI.java:38)
	at org.jdesktop.applet.util.JNLPAppletLauncher.startSubApplet(JNLPAppletLauncher.java:1889)
	at org.jdesktop.applet.util.JNLPAppletLauncher.access$200(JNLPAppletLauncher.java:650)
	at org.jdesktop.applet.util.JNLPAppletLauncher$5.run(JNLPAppletLauncher.java:1261)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

Here is the snippet where the callAndWait is called in GUI.init


    /** Initializes the applet GUI */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    loadImages();
                    initComponents();
                    initDraggableComponents();
                    myGlassPane = new MyGlassPane();
                    setGlassPane(myGlassPane);
                    initListeners();
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

And here is the html file…

<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
     width=840
     height=570
     archive= "http://download.java.net/media/applet-launcher/applet-launcher.jar,
               http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
               http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
               http://www.cs.rpi.edu/~yildih2/pcsdt/test/swing-layout-1.0.jar,
		 http://www.cs.rpi.edu/~yildih2/pcsdt/test/pcsdt.jar">
  <param name="codebase_lookup" value="false">
  <param name="subapplet.classname" VALUE="pCSDT.GUI">
  <param name="subapplet.displayname" VALUE="PCSDT Applet">
  <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="1">
   <param name="jnlpExtension1" value="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp">
   <param name="cache_archive" VALUE="jogl.jar,gluegen-rt.jar,pcsdt.jar">
  <param name="cache_archive_ex" VALUE="jogl.jar;preload,gluegen-rt.jar;preload,swing-layout-1.0.jar;preload,pcsdt.jar;preload">
</applet>

Thanks,

The invokeAndWait() call inserts a Runnable into the AWT Event Queue and the calling Thread waits until this Runnable is executed by the AWT Event Thread. This can only work, if you are not already in the AWT Event Thread. I would assume, that the applets init() is always on the Event Thread, so just leave out the Runnable and the invokeAndWait. If you are unsure, you can test if the current Thread is the EventThread with some SwingUtilities method and decide yourself to wrap the init code into a Runnable or not. If you don’t rely on the init code to be finished by the end of the init()-method, you could also use invokeLater() instead of invokeAndWait().