We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Applet preloading -- a workable solution
Page Index Toggle Pages: 1
Applet preloading -- a workable solution? (Read 731 times)
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
Re: Applet preloading -- a workable solution?
Reply #1 - Apr 1st, 2008, 8:49pm
 
Greg, this is great.  I haven't checked out the code yet, but yes, I, for one, would definitely be interested in this preloader functionality.  Thanks for hacking away at this!
Re: Applet preloading -- a workable solution?
Reply #2 - Apr 3rd, 2008, 8:41am
 
Well i would definitely appreciate this.
Re: Applet preloading -- a workable solution?
Reply #3 - Apr 4th, 2008, 10:47pm
 
Ok, I finally got around to making a somewhat reliable package for this. Check out the demo online, and download the .zip file:

http://www.andrewberman.org/projects/preload/

It's also not exactly well tested, to please let me know if you find any problems! There is a README.txt within the zip file that has some useful information; otherwise, the main components are index.html, build.xml, src/org/freeloader/freeloader.java, and scripts/appletloader.js.

Cheers,
 greg
Page Index Toggle Pages: 1