FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Integration
(Moderators: fry, REAS)
   Processing/ Java Preloader
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Processing/ Java Preloader  (Read 5695 times)
Craig


Processing/ Java Preloader
« on: Apr 15th, 2005, 10:55pm »

Most Flash websites use an Actionscript preloader - ( you know a small file that loads a big file and tells you how much has loaded with a progress bar, a percentage and / or how many bytes  loaded).
 
But most Java applets (including those made in Processing) just show a coffee cup with no indication of what is being loaded or how long it will take.  
 
Now only programmers know what the coffee cup means and not knowing how long something takes to load is frustrating for anybody. This strikes me as very poor HCI design.
 
I really want to use Processing and Java instead of Flash but this is a stumbling block - so my question is does anybody know how to build a preloader in Processing or Java or both?
 
Sorry for the moan but I really want to leap this hurdle.
 
Craig
 
fry


WWW
Re: Processing/ Java Preloader
« Reply #1 on: Apr 16th, 2005, 3:00am »

good question... that coffee cup thing seems to have reappeared (instead of just a gray box) in java 1.5 or so. my concern would be that java itself starting up is taking a lot of the time.  
 
i seem to remember seeing an example for doing this in java a long while back but would be curious if it would help, might even be something we'd build in if it really helped things. anyone care to google this one a bit?
 
gll

WWW Email
Re: Processing/ Java Preloader
« Reply #2 on: Apr 16th, 2005, 6:45am »

Some time ago, I tried something about the preloaders.
I spend too much time on this with no results
Anyway, here's what I've found;
http://www.rgagnon.com/javadetails/java-0025.html
 
---------------------------------
[HTML (testQuick.html)
---------------------------------
<HTML><HEAD></HEAD><BODY>
<APPLET CODE="QLoader.class"  
   NAME="QLoader"
   HEIGHT=200  
   WIDTH=200>
<PARAM NAME="appletToLoad" VALUE="SecondApplet">
<PARAM NAME="SecondAppletParm" VALUE="Hello World">
</APPLET></BODY></HTML>
 
---------------------------------
[JAVA source (QLoader.java)]
---------------------------------
import java.applet.Applet;
import java.applet.AppletStub;
import java.awt.*;
 
public class QLoader extends Applet  
    implements Runnable, AppletStub {
  String appletToLoad;
  Thread appletThread;
 
  public void init() {
    appletToLoad = getParameter("appletToLoad");
    setBackground(Color.white);
    }
 
  public void paint(Graphics g) {
    g.drawString("Loading the BIG ONE ...", 30, 30);
    }  
 
  public void run() {
    try {
 Class appletClass = Class.forName(appletToLoad);
 Applet realApplet = (Applet)appletClass.newInstance();
 realApplet.setStub(this);
 setLayout( new GridLayout(1,0));
 add(realApplet);
 realApplet.init();
 realApplet.start();
 }
    catch (Exception e) {
 System.out.println( e );
 }
    validate();
    }
 
  public void start(){
    appletThread = new Thread(this);
    appletThread.start();
    }
 
  public void stop() {
    appletThread.stop();
    appletThread = null;
    }
 
  public void appletResize( int width, int height ){
    resize( width, height );
    }
}
 
---------------------------------
[SecondApplet.java for demonstration]
---------------------------------
import java.awt.*;
 
  public class SecondApplet extends java.applet.Applet {
    TextField tf;
    public void init() {
 System.out.println("Starting Second applet");
 String s;
 tf = new TextField( 10 );
 add( tf );
 s = getParameter("SecondAppletParm");
 tf.setText(s);
 }
    }
 
 
**Note: I was using a simple alternative some time ago to replace the coffee cup and the gray background. I doesn't seems to work with 1.5. You could change the gray background with your dreamed color by adding some paramaters inside your HTML code. It was working with IExplorer and Opera, but I'm not sure with FireFox. Making a great preloader will be nice, in particular for heavy Sonia projects. Anyway, here's a sample code I use:
 
<applet code="myApplet" archive="myApplet.jar" width=500 height=550>
<param name="progressbar" value="true">
<PARAM name="boxmessage" value="Please, Be Patient, my server is so popular...">
<PARAM name="boxbgcolor" value="#FFFFFF">
<PARAM name="boxfgcolor" value="#aaaaaa">
<param name="progresscolor" value="#FFEFCa">
</applet>
 

guillaume LaBelle
Pages: 1 

« Previous topic | Next topic »