gjuggler
YaBB Newbies
Offline
Posts: 33
Applet preloading -- a workable solution?
Mar 20th , 2008, 6:51pm
I've been tinkering with ways to get around the annoyances of Java applet loading for awhile now, as I've got a couple projects underway that create applets of several megabytes in size. The usual "blank white screen and unresponsive webpage until everything is loaded" just isn't good enough, so I've been investigating the possible alternatives. In particular, Fjen's AppletObject ( http://appletobject.org/ ) is quite a good Javascript solution to the problem. It uses some HTML trickery to create a preloading progress bar for a given applet, and then -- once all the .jars have been "preloaded" -- it will cause your desired applet to appear. However, AppletObject has some drawbacks. Not due to problems of implementation, but due to limitations that are inherent within the approach itself. Firstly, when you refresh the page after having preloaded the applet once already, the reloading is not instantaneous as it is when you simply embed the applet. Secondly, Internet Explorer doesn't seem to like the way AppletObject preloads the classes. For IE7 on Windows Vista, it always complains in one way or another. Today I finally decided to hunker down and try the alternative option -- a Java-based preloader for applets. This has already been done before (notably in the elegant "anagramic greetings" found here: http://www.thesystemis.com/new_years/ ), but I haven't managed to find a flexible, open-source implementation of this strategy. So, here is my best attempt: http://www.andrewberman.org/projects/preload/ There's a bunch of sneakery going on behind the scenes, but basically what's happening is the browser first loads the FreeLoader applet, which is fairly small in size. The applet then starts showing a pretty loading animation. Meanwhile, in a background thread, FreeLoader loads up the other jars from the project, and when it's finished, finally causes the destination applet to be launched. I think this is a vast improvement over the standard <applet> tags, and it beats out the JavaScript solutions because upon refresh, the applet is cached and loads almost instantaneously. Anyway... this is the "integration" board, so you may be wondering how to integrate this with your project? Unfortunately it can't be packaged up into a Processing library (it's a combination of html and javascript too), but I'm working on putting together a FreeLoader-enabled build system that works right out of the box. This would let you write your code in Processing's "advanced" mode, and then use Apache Ant to build the applet and webpage. Would anybody actually end up using this? Let me know if you have comments or suggestions. greg