Applet Demo smooth download and splash (Updated 2007-12-13) : New version

Hum, this solution have some issue but it is fully compatible with all JVM, basically your load this applet using the above “3DzzDAppletScript.js” and replace int code this.appletToLoad=“TestSimpleParticle”; by applet you would like to load.

Good things are : fully compatible all JVM, and near imediate starting of the Applet, does not requiere applet modification, allow customizing animation while loading

Bad things are: this does not allow use of archive applet tag (.jar),so to allow the applet to run you must expand your .jar server side, you have no information about loading progress.


/**
 * Boot Applet Loader
 *
 * @author bruno augier
 * @email bruno.augier@dzzd.net
 * @website http://dzzd.net/ 
* @version 1.00 07/12/05
 */
 
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.lang.reflect.*;


public class BootAppletLoader extends Applet implements Runnable
{
	private Container panel;
	String appletToLoad;
	
	
	public void init()
	{	
		this.panel = this.getParent();
		this.appletToLoad="TestSimpleParticle";	
		Thread t=new Thread(this);
		t.start();
	}
	
	public void run()
	{
		try
		{
			Applet a=(Applet)(Class.forName(this.appletToLoad)).newInstance();
			panel.add(a);
			panel.remove(this);
			Dimension d=this.getSize();
			a.setSize(d.width,d.height);
			a.init();			
			a.start();

		}
		catch(ClassNotFoundException cnfe)
		{
			cnfe.printStackTrace();
			
		}
		catch(InstantiationException ie)
		{
			ie.printStackTrace();
			
		}
		catch(IllegalAccessException iae)
		{
			iae.printStackTrace();
			
		}			
	}

	public void paint(Graphics g) 
	{
		this.update(g);
	}
	
	public void update(Graphics g) 
	{
		g.drawString("Loading applet please wait", 50, 60 );
	}	
}

The above is a first try, I found another solution but it requiere a little serverside script, but this one allow archive tag use and progress monitoring and an immediate starting of a boot applet. not finished yet…

JavaScript updated:

Better Jar and classe file cache, enable fast switch between applets once an applet have been loaded it can be started immediatly

http://demo.dzzd.net/JScripts/index2.htm

Got a problem with it in FireFox 2.0.0.11, WinXP, Java 1.6: gif is spinning forever, console is clear (all applets except first one). On IE everything is just fine.

Hmmm I have same config, but FF will freeze for several seconds and not animate or max one tick before applet starts ???. IE seems to be mostly OK, except for a hickup from a page reload. Didn’t use to be there did it? For me, this last version was a small step back. :-\

[quote]For me, this last version was a small step back.
[/quote]
yup i think so…

will try to improve it, I began to refound it from scratch

this page use another version:
http://demo.dzzd.net/EARTH/

let me know if you find problems on it

new version, hope this one will works everywhere… seems that FF always hang few second, IE & Safari seems OK…

Waiting feedback from MAC & Linux users please.

demo using this loader:
http://demo.dzzd.net/EARTH/
http://demo.dzzd.net/JScripts/index2.htm
http://demo.dzzd.net/JScripts/

 
/**
       * 3DzzDAppletScript.js
       *
       * This source code is a part of 3DzzD Web 3D engine you may use it as long as you provide the orignal source author and website and this comment unmodified
       *
       * @author bruno augier
       * @email bruno.augier@dzzd.net
       * @website http://dzzd.net/
       * @version 1.00 2007/12/03
  */
  
  var jvmInited=false;
  var imageLoad=new Image();
  imageLoad.src="INIT.GIF";
  var preloadingJar = new Array();
  
  function loadApplet(targetAppletId,appletName,appletTag,width,height,preloadJarFiles)
  {
    if(document.getElementById(appletName))
		return;	
    
    var msg="Loading Applet "+ appletName;
    window.status=msg;
	var target=document.getElementById(targetAppletId);
	var html="";
    html+="<TABLE ID=\""+targetAppletId+"LOADER\" cellSpacing=0 cellPadding=0 WIDTH=\""+width+"\" HEIGHT=\""+height+"\" STYLE=\"border:0\" >";
    html+="<TR><TD vAlign=\"center\" align=\"middle\">";
	html+="<IMG ";
    html+=" ALT=\""+ msg + "\" ";
    html+=" SRC=\"INIT.GIF\" ";
    html+=" >";
    html+="</TD></TR></TABLE><DIV STYLE=\"visibility:hidden\" ID=\""+targetAppletId+"APPLET\"></DIV>";	
	target.innerHTML=html;
	var nbApplet=document.applets.length;
	
	if(preloadJarFiles!=null && preloadJarFiles.replace(" ","")!="")
	{
		preloadJars(preloadJarFiles);
		setTimeout("showAppletOnceStartedPreload(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\",\""+preloadJarFiles+"\","+nbApplet+")",100);
	}
	else
	{
		setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",100);
	}	
  }
  
  function showAppletOnceStartedPreload(targetAppletId,appletName,appletTag,width,height,preloadJarFiles,nbApplet)
  {
	if(!isJarsPreloaded(preloadJarFiles))
		setTimeout("showAppletOnceStartedPreload(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\",\""+preloadJarFiles+"\","+nbApplet+")",1250);
	else
		setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
  }
  
  function showAppletOnceStarted(targetAppletId,appletName,appletTag,width,height,nbApplet)
  {
    var target=document.getElementById(targetAppletId+"APPLET");
	
	if(target.innerHTML.toUpperCase().indexOf("<APPLET ")==-1)
	{
		target.innerHTML+=appletTag;
		setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
		return;
	}
	
    if(jvmInited)
	{
		if(document.applets.length>nbApplet)
		{
		    var applet=document.getElementById(appletName);
			if(applet!=null)
			{
				if(document.applets[appletName])
				{
					var msg="Applet loaded and started " + appletName;
					window.status=msg;
					setTimeout("showApplet(\""+targetAppletId+"\",\""+appletName+"\",\""+width+"\",\""+height+"\")",250);
					return;
				}  
			}
		}
	}
	setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
  }
  
  function showApplet(targetAppletId,appletName,width,height)
  {
	var applet=document.getElementById(appletName);
	var loader=document.getElementById(targetAppletId+"LOADER");
  	loader.style.display="none";
	applet.width=width;
	applet.height=height;
	applet.style.width=width;
	applet.style.height=height;
	var target=document.getElementById(targetAppletId+"APPLET");
	target.style.visibility="visible";
  }
    
  function preloadJars(files)
  {
	var fileArray=files.replace(";",",").split(",");
	for(var c=0;c<fileArray.length;c++)
	{
	 preloadJar(fileArray[c]);	
	}  
  }

  
  function isJarsPreloaded(files)
  {
	var fileArray=files.replace(";",",").split(",");
	for(var c=0;c<fileArray.length;c++)
	{
		if(!fileArray[c])
			return false;
	}
	return true;
  }

  function isJarPreloaded(name)
  {
	if(preloadingJar[name]==null)
		return false;
		
	return preloadingJar[name];	
  }
  
  function preloadJar(name)
  {
	   
	   if(preloadingJar[name])
		return;
       preloadingJar[name]=false;
       var f=window.frames[name];
       if(!f)
       {
            document.body.innerHTML+="<IFRAME NAME=\""+name+"\" WIDTH=0 HEIGHT=0 STYLE=\"border:0\"></IFRAME>";
            f=window.frames[name];
            f.document.open("text/html");
            var iframeHTML="";
            iframeHTML+="<HTML><BODY onload=\"parent.preloadingJar['"+name+"']=true;\" SCROLL=NO STYLE=\"margin:0\" >";
            iframeHTML+="<APPLET ARCHIVE=\""+name+"\" NAME=\""+name+"\" WIDTH=0 HEIGHT=0 ";
            iframeHTML+=" CODE = \"java.applet.Applet\" ";
            iframeHTML+="</APPLET>";
            iframeHTML+="</BODY></HTML>";
            f.document.write(iframeHTML);
            f.document.close();
       }
  }
  var initJVMCount=0;
  /**
       * Initialise Java JVM, this may hang few seconds
  */
  function loadJVM()
  {
       if(jvmInited)
       return;
       if(initJVMCount>15)
       {
            if(confirm("Java Plugin requiered, do you want to instal Java Plugin ?"))
            window.location.href="http://java.com/";
            jvmInited=true;
            return;
       }
       var f=window.frames["JVMLOADER"];
       if(!f)
       {
            document.body.innerHTML+="<IFRAME NAME=\"JVMLOADER\" WIDTH=0 HEIGHT=0 STYLE=\"border:0\"></IFRAME>";
            f=window.frames["JVMLOADER"];
            f.document.open("text/html");
            var iframeHTML="";
            iframeHTML+="<HTML><BODY SCROLL=NO STYLE=\"margin:0\" >";
            iframeHTML+="<APPLET WIDTH=0 HEIGHT=0 ";
            iframeHTML+=" CODE = \"java.applet.Applet\" ";
            iframeHTML+="</APPLET>";
            iframeHTML+="</BODY></HTML>";
            f.document.write(iframeHTML);
            f.document.close();
       }
       if(f.document.applets.length==0)
       {
            setTimeout("loadJVM()",2000);
            initJVMCount++;
            return;
       }
	   
       // Workaround for Safari 3.0.4 embeded code crash windows XP with safari ?!
       if(navigator.userAgent.toUpperCase().indexOf("SAFARI")==-1)
       {
            try
            {
                 if(!f.document.applets[0].isActive())
                 {
                      setTimeout("loadJVM()",500);
                      initJVMCount++;
                      return;
                 }
            }
            catch(e)
            {
                 setTimeout("loadJVM()",500);
                 initJVMCount++;
                 return;
            }
       }
       jvmInited=true;
       f.document.open("text/html");
       var iframeHTML="";
       iframeHTML+="<HTML><BODY SCROLL=NO STYLE=\"margin:0\" >";
       iframeHTML+="</BODY></HTML>";
       f.document.write(iframeHTML);
       f.document.close();
  }

Hmm, I tried the Earth demo on FF/Mac… after the loading gif it says “applet started” in the status bar but it doesn’t just the applet - it’s just black.

Worked ok in Safari.

Black background is faster ;D

Nice work though, everyone, good discussion… I’m highly interested in this topic as we all are!

Once again another try with another JavaScript code, this loader make me become crazy… browsers have so much differences… liveconnect dont works on some, javascript to java dont work on some other… is it easy to make s smooth loader for IE, this is not easy for other browser…

anyways feedback for this try are welcome:
http://demo.dzzd.net/PLANETARIUM/

Wow, that really f***edup firefox good!

The paged hanged with the following output to the java console:


Exception in thread "Thread-6" java.lang.NullPointerException
	at ZarchApplet.paint(Unknown Source)
	at ZarchApplet.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
com.zerog.ia.download.WebInstallerApplet[panel0,0,0,0x0,invalid,hidden,layout=java.awt.FlowLayout]
sun.plugin.AppletViewer[com.zerog.ia.download.WebInstallerApplet,0,0,525x85,invalid,layout=java.awt.BorderLayout]
sun.plugin.viewer.frame.WNetscapeEmbeddedFrame[frame0,0,0,525x85,invalid,layout=java.awt.BorderLayout,title=,resizable,normal]
initializing AppletResourceBundle strings for en
input stream is null
Platform :  windows
VM Vendor:  sun
VM Version: 1.6.0_02
IsSupportedVM:  true
-----------------------
Java Vendor:  Sun Microsystems Inc.
URL:  http://java.sun.com/
Java Version:  1.6.0_02
Java Class Version:  50.0
OS Name:  Windows XP
OS Architecture:  x86
OS Version:  5.1
---------------------------------
Timeout set to :30000
immediateInstall:  false
Trouble e-mail address:  yourEmailAddressHere
installerNameVM: 
installerNameVM: Windows/VM/CollabTraining_Installer.exe
Reading applet parameters: Reading in data for platform #1; platform name = Windows
Reading applet parameters: Platform #2 not found.
Reading applet parameters: Platform #3 not found.
installerNameVM: 
installerNameVM: Linux/VM/CollabTraining_Installer.bin
Reading applet parameters: Reading in data for platform #4; platform name = Linux
Reading applet parameters: Platform #5 not found.
Reading applet parameters: Platform #6 not found.
installerNameVM: 
installerNameVM: null
installerNameVM: null
Reading applet parameters: Reading in data for platform #7; platform name = Mac OS X
Reading applet parameters: Platform #8 not found.
Reading applet parameters: Platform #9 not found.
Reading applet parameters: Platform #10 not found.
Reading applet parameters: Platform #11 not found.
Reading applet parameters: Platform #12 not found.
Reading applet parameters: Platform #13 not found.
Reading applet parameters: Platform #14 not found.
Reading applet parameters: Platform #15 not found.
Reading applet parameters: Platform #16 not found.
Reading applet parameters: Platform #17 not found.
Reading applet parameters: Platform #18 not found.
Reading applet parameters: Platform #19 not found.
Reading applet parameters: Platform #20 not found.
currentOS = Windows XP
runOnPlatformsContainingString = Win
curPlatformSubstring = Win
* Found: Running on platform: Windows

Does Installer with VM exist: true
Does Installer no VM exist:   false
Is this Platform Unix:        false

failed to resolve user.home, assuming unsigned and cannot execute
Is unable to execute files because of permissions
java.lang.NullPointerException
	at sun.plugin.AppletViewer.loadJarFiles(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:485)
	at sun.plugin.ClassLoaderInfo.lock(Unknown Source)
	at sun.plugin.AppletViewer.loadJarFiles(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

I could no longer open the other tabs in FF. Menus and toolbar buttons seemed to be ok. But when I typed in the url textfield the text went backwards, from right to left. Closed FF and when I opened it again and got a message that FF was still running. Had to kill it from the taskmanager.

Firefox 2.0.0.11, Windows XP

That console output seems to come from another applet. This applet probably halted /didnt close properly before starting ours (I had this occasionally myself. FF & applet exceptions dont really go along nicely, always need to kill it trhough the taskmanager)

Could you retry by going to the link directly?

Tried it again and now it worked. Well, the loading hangs when trying to view a third planet.

[quote]Tried it again and now it worked. Well, the loading hangs when trying to view a third planet.
[/quote]
yup, sry my fault, forgot to release applets ressources and threads on destroyed/stopped… so heap is growing up…: implementing destroy method and releasing ressource and thread should fixe most of thoses bugs…

I apologize…

[quote]Exception in thread “Thread-6” java.lang.NullPointerException
at ZarchApplet.paint(Unknown Source)
at ZarchApplet.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[/quote]
this mean that I am not alone to forget releasing thread :), I guess you played zarch before looking to this applet.

Zarch is a 4K game thought. It will not usually follow the rules.

no prob, ofcourse, i know this is mormal/common issue in 4k games

Just so you know I got this crash:

[quote]java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.(Unknown Source)
at dzzd.k.(Unknown Source)
at dzzd.e.a(Unknown Source)
at dzzd.e.setSize(Unknown Source)
at dzzd.V.setSize(Unknown Source)
at dzzd.DzzDApplet.a(Unknown Source)
at dzzd.DzzDApplet.start(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[/quote]

thanks I may review that later as I do not work anymore on this tools, too many things to do… as everybody…