Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

Dynamic user interface is only skin deep

Java skins are an alternative approach to a pluggable look and feel

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
A skin is a collection of images and a definition file, which together describe an application interface. You have no doubt come across applications using skins already. On Windows, Linux, and other operating systems, an increasing number of applications (and games) allow users to completely change the look and feel of the user interface. The packages used to implement these design changes are usually called skins.

Winamp -- an MP3 player by Nullsoft (see Resources for more info) -- is one application that uses skins. Nullsoft actively encourages skin development for Winamp, and, according to its Website, more than 5,000 skins are currently available. Games such as Quake III Arena use skins to allow players to select the characters who will represent them during play, and create entirely new characters. Skins even help you alter the look of your operating system desktop according to your whims.

Why should you use skins? Well, if you write applets, especially for the Internet, and cannot guarantee that your user base already has JDK 1.2 installed, or has access to broadband, there is significant overhead with downloading Swing. The same argument applies if you write a downloadable application, or one in which the application size may be an issue.

Another advantage to using skins is you can fit a pre-existing library of lightweight components into a dynamic (skin-based) model without too much pain. If you have ever worked with a designer, then you probably spent hours reworking your layouts to make a minor modification to the interface design. Use a skin, and the design can be altered in a few moments without the need to recompile. Better yet, skins allow you to hand over complete control of the interface layout to your designer.

There are also marketing considerations. Winamp might not have been as popular if more than 5,000 designs were not available for download. But skins' big selling point for me is the fact that after I brand an application for one company, I can rebrand it for another company, or for a shrink-wrapped version, quickly and easily.

Note: to download the complete source code for this article as a zip file or in tar.gz format, see Resources.

How it works

The specification of a basic customizable interface is relatively simple. You'll need:

  • A new layout manager
  • A properties file that contains information about how the interface is laid out
  • An ImageLabel (lightweight) component for noninteractive areas of the screen
  • An ImageButton (lightweight) component for interactive areas of the screen
  • Other lightweight components as necessary for the application


The following code samples define the most basic lightweight components -- the ImageLabel and ImageButton. Those who already have a library of lightweight components should skip ahead to the layout manager definition.

ImageLabel.java

The following code implements the ImageLabel lightweight component, rendering an image onto a supplied graphics context. Please note that a utility class -- Utils -- is used for loading images:

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (3)
Login
Forgot your account info?

handbagsBy Anonymous on October 26, 2009, 8:21 amreplica handbags wholesale handbags replica designer handbag

Reply | Read entire comment

legal term By adam156 on May 12, 2009, 11:51 pmReal estate is a legal term (in some jurisdictions, notably in the USA, United Kingdom, Canada, and Australia) that encompasses land along with anything permanently...

Reply | Read entire comment

commentBy Anonymous on April 20, 2009, 12:02 amcomment

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources