Skip to main content

A Better Applet Experience, Part 1: a custom loading screen

Posted by joshy on August 14, 2008 at 5:55 PM PDT

You may have heard that JavaSE 6 update 10 is supposed to improve the experience of applets. You may have even seen the demos of dragging and dropping applets out of the webbrowser, but there's a lot more to it than that. In this series of blogs I'll show you how to get the most out of deploying your applets, even if you aren't using Update 10.

Getting rid of the coffee cup logo

The first thing many people complain about is the coffee cup logo when loading Java applets. It's different depending on the exact OS and JVM version you have, but it always looks something like the image to the right.

This bothers app developers for many reasons, including branding a product other than their own, breaking the visual look of their application, and the excessive usage of orange. All good critiques. But I'm here to tell you it doesn't have to be this way. The orange logo is just a default. You easily can, and should, change the loading screen to another image which fits in with the rest of your website.

Long before the advent of Java SE 6 update 10 the applet plugin has supported using a custom image for the loading screen. Just set the image parameter of the applet. That's it! Here's an example:

<applet code="animatedstartup.MainApplet"
        archive="AnimatedStartup.jar"
        width="100" height="100"
        >
    <PARAM name="image" value="earth.gif"/>
    <PARAM name="boxmessage" value="loading..."/>
    <PARAM name="boxborder" value="false"/>
</applet>

The image parameter will set a loading image. Update 10 also adds support for a loading message and turning off the applet border, but the image parameter is the important one. This example will look like this:

screenshot

Making an animated loading screen

Java 6 has recently added support for animated loading screens by using animated gifs. The earth.gif image I used in the previous example is actually the animated gif seen here . If you have a recent plugin then the loading screen will be animated as well. Of course you might want a spinner that's a bit more appropriate like the ones you can get from here:
You could also use a gif more indicative of loading such as this one

from here.

For more on the applet loading screen see the
special
attributes section
of the deployment documentation and the


notes on the new Java plugin
.

That's it for this week. You can see the live version of this demo here. Next time I'll show you how to make a screenshot which is replaced by the real applet when you run it.

Comments

I would not say this is such a great addition, what we really need is the api to control progress bar and or to be able to change the loader. I love java with all my heart but, common now, this is 21th century, changing the picture? and that is called a new "cool" feature?

Also tested this on Mac OS X 10.5.4 Same results with Safari as the Windows version. Firefox 3 fails to show the spinning globe completely though.

I'm currently working on porting our open source swing application to an applet, we have many Mac users and I've found the Plugin on the mac flickers a lot more then the windows version, when will Java 6u10 be available for OSX? This item listed above is certainly helpful, but only gets us so far. Do you have any tips for packaging your applet for optimal start up time? Our application is very large and I was trying to figure out if we could somehow stage the download so that you needed a minimal # of classes (jar size) to get going.

wow, this makes a happy man! now if only you could become better friends with the fruit basket and penguin people to release new jre versions all at the same time java would finally where flash has been for a long time (in that one aspect)

it would be great to have a xml schema to enable IDE validation (and auto completion) for the jnlps. docs like those: http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguid... are great but they are not machine readable.

Good info! Our main complaint is that you lose the progress bar when you replace the default image with your own. There aren't many options if it takes a little bit to load your applet.

Oh. I thought it would work in older versions because of what was written above "I'll show you how to get the most out of deploying your applets, even if you aren't using Update 10."

pepejeria, i tried it as well and had the exact same results. After updating to update 10, it was better. with update 10 it went from the trademark gray applet rectangle (2-3 secs), to the animated gif (3-4 secs), to 'applet loaded'.

Update: I get the same results as in Firefox 3 using IE 7 and Safari 3.1. The applet appears above the text while loading in Opera 9.51

Just tested the demo in Firefox 3 running on Windows Vista. First time you load the page you only the the globe for a millisecond before the applet done message is shown. Reloading the page result in the globe being shown, but it is not animated... Using Java 1.6, update 7. Is this demo only for users with update 10?

Good news! One question: The default logo with Java and Cup also has a progress small bar showing the applet's download state. What happens with that progress bar when I use a custom image? Is it possible to provide some custom progress visualization?

Holy smoke, thats awesome! How long has this been in applets ? Look forwards to more parts on this. Keep it up!