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.
Page Index Toggle Pages: 1
pre loader? (Read 1816 times)
pre loader?
Jan 6th, 2006, 12:03am
 
Greetings all. I'm new to processing and these boards, and I can't for the life of me figure out how to make a simple pre-loader? I'm making a web based app, and while creating an image loader seems pretty easy, making a loader for the applet is proving difficult. Does anyone have any suggestions for how to make a load bar for the applet itself when it is viewed online?

I would think this is a pretty common issue, but I haven't been able to find a simple solution. Any help would be much appreciated.

ni9e-2-fi5e
Re: pre loader?
Reply #1 - Jan 6th, 2006, 12:13am
 
Unfortunately there is no good way to make a preloader in Java.  The problem is that Java needs to load the classes itself before before it can execute them, but if you make a preloader, you have no control or access over that load operation to give some kind of progress.  The best you can do in that respect is make a preload/splash screen that shows .jar files sequentially being loaded.  Unfortunately, my attempts to trick java's cache by loading the .jar files directly, myself, then letting java pull them from cache for the actual class loading has not been successful.  This makes it impossible to give a realistic progress bar.

If you have multiple jar files, Java loads them in order until it finds the class you requested, if you try to request a class that doesn't exist, it'll load all the jar files first.  You can use this to your advantage by requesting one class from each jar file, in order, and displaying a fairly chunky progress bar for each (you could even calculate the time to load the first jar file, and extrapolate the other jar files based on that to get a prediction).

Ok, so that's the general method.  There is one other method, and that involves using some special features in the Java plugin.  You'll notice processing (in later builds) displays the logo while it's downloading the jar files.  You can change the logo to anything you want, plus, in addition, if you look around, some versions of the java plugin allow you to specify a progress bar (color, position, etc.).  I believe this feature was added in some 1.3.x release, changed in 1.4, and changed yet again in 1.5 (not sure if 1.5 lets you change it, I haven't looked recently).

In short, there's no one good way to do it.  The best you can do is make a mini class that tells the user that something is loading (although this won't be displayed until the JVM starts, one reason to use the method processing uses).  That could even have some kind of animation, but there's no decent way (that I have found) to do a progress bar.

Hope that helps!  Maybe some other people have some advice or have thought about this.

Marcello
Re: pre loader?
Reply #2 - Jan 6th, 2006, 4:04am
 
i think that for a time they may have turned the progress bar "on" by default, then shut it back off again (maybe with 1.5?)

perhaps setting progressbar to true in the applet tags (and customizing the color/text to your liking) would work:
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/special_attributes.html

oddly, this seems to have disappeared in 1.5:
http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/special_attributes.html

let us know what you find...
Re: pre loader?
Reply #3 - Jan 8th, 2006, 12:58pm
 
hi fi5e,
long time no see...

this very topic has always bummed me out.  You can load classes progressively (IE http://thesystemis.com/new_years/) but you get no feedback in java about the number of bytes that have been loaded, etc, etc.

maybe there is a way to use javascript / ajax to progressively load the page and offer feedback on the loading process.  I've seen the opposite, for server based uploads:

http://sean.treadway.info/demo/upload/

and have always wondered if it could be done for downloads.

good luck !

- z
Page Index Toggle Pages: 1