Intro while loading large applet


Loading my applet takes 3 seconds intranet) up to 4 minutes (dial up connection with GSM Handy).
Therefore I´m looking for a solution, that shows a hint on the screen while loading the applet (something like: loading applet. Please wait ...). The solution should
be quit simple, and work with all browsers of release 4 or higher.

Is there anybody who has an idea?

Thanks in advance Kurt
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you are using frame, you can put up a loading.gif, that will show that applet is loading.

Once the page with applet is loaded, this page's href can be changed.

I know a way of doing a loading screen, but it depends on what youre loading into your applet, if its images then yes i know, overwise, i cant help.

Take a loot at the AppletStub class. The following is a program from Java Experts. This uses a applet stub to display a msg till the underlying applet is loaded.

import java.applet.Applet;
import java.applet.AppletStub;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;

// This applet is responsible for loading another applet in the
// background and displaying the applet when it finishes loading.
// The name of the applet to load is supplied by a <PARAM> tag.
// For example:
// <PARAM name="applet" value="RealApplet">
// which would load an applet class called RealApplet
public class QuickLoader extends Applet implements Runnable, AppletStub
     String appletToLoad;
     Label label;
     Thread appletThread;

     public void init()
// Get the name of the applet to load
           appletToLoad = getParameter("applet");

// If there isn't one, print a message
           if (appletToLoad == null) {
                 label = new Label("No applet to load.");
           } else {
                 label = new Label("Please wait - loading applet "+

     public void run()
// If there's no applet to load, don't bother loading it!
           if (appletToLoad == null) return;

           try {

// Get the class for the applet we want
                 Class appletClass = Class.forName(appletToLoad);

// Create an instance of the applet
                 Applet realApplet = (Applet)appletClass.newInstance();

// Set the applet's stub - this will allow the real applet to use
// this applet's document base, code base, and applet context.

// Remove the old message and put the applet up


// The grid layout maximizes the components to fill the screen area - you
// want the real applet to be maximized to our size.

                 setLayout(new GridLayout(1, 0));

// Add the real applet as a child component

// Crank up the real applet
           } catch (Exception e) {

// If we got an error anywhere, print it
                 label.setText("Error loading applet.");

// Make sure the screen layout is redrawn

     public void start()
           appletThread = new Thread(this);

     public void stop()
           appletThread = null;

// appletResize is the one method in the AppletStub interface that
// isn't in the Applet class. You can use the applet resize
// method and hope it works.

     public void appletResize(int width, int height)
           resize(width, height);
Improving Applet Startup Time

When you are creating a commercial Web page that is covered with Java applets, you want to get results to the user as quickly
as possible. Web browsers tend to leave a big blank spot on the page where an applet is supposed to go. If your applet takes
30 seconds to load, someone may not be patient enough to wait for it. In fact, he may not even know there is an applet being
loaded. It would be nice if you could at least print a message telling the user that an applet is being loaded that is going to blow
his socks off, so he should sit in rapt anticipation for your wonderful-but-huge applet to be downloaded. As it turns out, this is a
snap! You can create a very small applet that downloads the real applet in the background. The only trick to this is that when
you create an applet manually, it doesn't know its code base or document base. It does, however, have a method called
setStub that tells it where to go for this information. Almost every method in the AppletStub interface is implemented in the
Applet class, which means that your loader applet can act as an applet stub for another applet. The only method in the
AppletStub interface that isn't in the Applet class is appletResize. Your appletResize method can simply call the resize
method in your loader applet, since that will perform the actual resize.

all the best.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

all these suggestion will work ONLY if you do not zip applet classes inside single .zip file, or if the browser supports multiple files inside the APPLET ARCHIVE tag.
heyhey_ how abt having 2 class files in the same directory?
iam neither using zip or archive.

as I already said this code won't work only if you use single archive (which is tha most common situation).
multiple archives or no archive at all is ok.
Kurt021099Author Commented:
To jsridhar:
Sorry, I do not use a frame.
Kurt021099Author Commented:
To boycey19:
Sorry, I do not show images with my applet.
your answer is:
'You can solve your problem if you don't pack your .class files, or if your target browsers support multiple archive files.'

Kurt021099Author Commented:
to sgoms, heyhey

I am unsing an archive to speed up the loading time. If I put the QuickLoader class into the archive, I think the browser loads the whole archive before starting the QuickLoader class.

Can you tell me more about multiple archive files?

You can have a look to my applet. It is controlling a device. Just enter at your browser. Password = 0. After loading the applet, it makes a connetion to the device useing port 8888. Maybe it gives you an idea.

I guess if u go in for multiple archive browser compaitability problem will arise 'cos all browsers may not support multiple archives.

how abt no archive? Quickloader will be the class that u fst load, then it will take care of loading ur applet.

Kurt021099Author Commented:
I would like to give sgoms the points. The solution is working perfect, if you do not use an archive.

that is so usefull, thx a lot :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.