Java 6 Gems: Spash Screen for your application | MyThinkPond

In my coverage of all the new features that are part of Java SE 6, there is a new gem added that makes the user experience very clean and concise when you bring up a web-start or applet or desktop based Java application. Namely, the splash screen.

When you load up a native application, it’s very traditional to display a “splash screen” with the company logo and branding of the particular product. In the past, you had to write your own loader class that did this. But now Java has added support for it. Class - java.awt.SplashScreen does the job for you.

The splash screen is displayed as an undecorated window containing an image. You can use GIF, JPEG, and PNG files for the image. Animation (for GIF) and transparency (for GIF, PNG) are supported. The window is positioned at the center of the screen (the position on multi-monitor systems is not specified - it is platform and implementation dependent). The window is closed automatically as soon as the first window is displayed by Swing/AWT
  • excerpt from the Java SplashScreen API

There are two ways to invoke the splash screen:

[sourcecode language=“jscript”]

java -splash:filename.png MyApplication

[/sourcecode]

or add it within your manifest.mf file like this

[sourcecode language=“jscript”]

Manifest-Version: 1.0 Main-Class: Test SplashScreen-Image: filename.png

[/sourcecode]

Now you have a common, concise way to display the splash screen. And if your application does anything like reloading classes or has a built in feature to restart certain parts of the application. You can even get the latest from a remote URL. Since it exposes, the following API [ setImageURL(URL imageURL) ], you can programatically invoke a URL like this on the server-side:

http://www.myapplication.com/getVersion.jsp?ver=1.2.3

And this can return a binary stream of “content-type: image/png”. But on the back-end you can tally the number of folks using version 1.2.3, etc.

Cheers.

If you find this article useful, consider signing up for my RSS feed or Email Newsletter. See links on the right side.
Venkatt Guhesan avatar
About Venkatt Guhesan
Enterprise Software Architect currently working at DataDirect Networks developing a highly scalable monitoring solution called DDN Insight. My passions include all things Open Source including Linux (CentOS, Red Hat, Gentoo, Open Stack, Docker & Ubuntu), embedded ARM processors and microcontrollers (Arduino, UDOO, Cubieboard, BeagleBoard, OnionIO, TI's Zigbee). Coming from an Electrical and Computer Engineering background, working in developing and designing enterprise - distributed, highly scalable software requires a unique set of software skills with a good understanding of the hardware. This makes his work challenging and interesting. In his free time, he spends his time with his family and two children. He also enjoys researching on topics including - world ancient history and yoga. Visit the 'About' section for more details.
comments powered by Disqus