A Better Applet Experience, Part 1: a custom loading screen
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>
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:
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
For more on the applet loading screen see the special attributes section of the deployment documentation and the
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.
Posted August 14th, 2008