This works… but I noticed that for big jar’s or slow connections, it looks like the plugin has crashed. People don’t associate this java logo & loading bar with the game datafiles loading but with Java not being able to boot up (we don’t want to have people think Java is slow again ;))
It was possible setting your own background image, which could accompany the progressbar with a loading text… but Sun has mysteriously chosen to drop support for the custom image/progressbar combination since 1.5… only offers a progressbar with the standard Sun loading screen, which will result in the misconception of Java not loading or being very slow.
I outlined an alternative in the JOGL applet post:
[quote]Another way of loading (large) resource files is by downloading the files runtime over an URLConnection with setUseCache enabled. A limitation is that it only caches files with a .jar or .class extension. You can make a zip containing all your images, sound etc and rename it to either .class or .jar. (for jar files you should use URL url = new URL (“jar:” + jarname + “!/”))
Another limitation of this technique is that you can’t monitor progress with caching enabled.
The advantage you have is that you gain more control over what to display as your applet is already up & running without waiting for the JVM archive jars to load…
Now I think of it, it might be possible to overcome the disability to monitor download progress with setUseCache enabled… You can implement your own protocol handler: http://java.sun.com/developer/onlineTraining/protocolhandlers/
What probably happens with setUseCache(true) is the handler streaming the resource to a file upon urlconnection.getInputStream(), it first downloads the whole resource into this file (in the plugincache) and then handles the stream over in one go. Maybe we could override the standard handler and enable reading the progress for the resource->file stream.
[/quote]
So downloading over a urlconnection with setUseCache(true) and the URL (“jar:” + jarname + “!/”)) is enough to download and cache your jar files runtime. You could display a splash screen or whatever you’d like during the download. There might be a hack possible to display your own progressbar (see details in the quote block), but i’ve never tested this. The idea is you can’t monitor the progress with setUseCache enabled is because upon the urlconnection.getinputstream, the protocol handler probably streams the entire conents of the url into a file (for .jar & .class extensions) in the plugin cache. To monitor this caching you could try to subclass the standard protocol handler… it’s worth a shot.
Thijs