Prior to 1.4.2, J2SE consisted of 3 pluggable Look-and-feel (PLAF) Designs:
Windows: Mimics the Windows 2000 operating system (Plaf can only be used under Windows platforms due to licensing restrictions).
Motif: Imitate the Motif application.
Metal: Use its own look-and-feel that is independent of any existing operating system.
The J2SE 1.4.2 offers two additional look-and-feel designs. John Zukowski describes both designs in the article "J2se 1.4.2 gets two new Look-and-feel designs" in his Magic column of Merlin (see Resources). The two new Look-and-feel designs are:
Windows XP: Mimic the Windows XP operating system (only under Windows platforms).
GTK +: Mimic the GTK application under Linux.
Feel better than to look good
For most people, the look-and-feel of an application is nothing more than a preference and appreciation. In some cases, however, it is necessary to customize the application's Look-and-feel to use a specific font, color mode, or icon. For example, some users of amblyopia often require look-and-feel to have a high contrast between text and background, as well as large fonts and icons. The IBM Java Accessibility Checklist (see Resources) stipulates that all user interface objects in an application must support High-contrast settings.
Early versions of the Java platform support for color and font preferences are not very good. Starting with J2SE 1.4, especially with the introduction of the new Windows XP and GTK look-and-feel design in J2SE 1.4.2, users can now configure the Look-and-feel design they want. Windows Look-and-feel tries to use the underlying color and font mode of the Windows platform, while GTK look and feel enables Linux users to customize Look-and-feel by defining some scripts.
At first glance, improvements in the "local" Look-and-feel design have made metal look and feel lose their role. On some occasions, however, Metal Look-and-feel (or its customized version) is still useful. For example:
If you need to be able to run under any platform, and even if it is used by an unsigned applet, it is a look-and-feel that can be customized.
If you need more customization capabilities that other Look-and-feel designs cannot provide.
If you are using an earlier version of the Java platform, the recent improvements to this version are not available.
This article explains how to modify the metal look-and-feel to use a specific font and color mode. You will also learn how to modify the icons used to draw widgets such as check boxes, radio buttons, trees, and file dialog boxes.
First I'll explain how to overload the colors and fonts used for Look-and-feel. Then we'll see how to modify the icons used by the standard widget. Finally, we'll look at a new Look-and-feel instance where you can define settings for colors, fonts, and icon sizes in a text file. You can then use our example to create a high-contrast look-and-feel.
Overload Metal look and feel--modify colors and fonts
The Javax.swing.plaf.metal.MetalLookAndFeel class is the main class of the metal look and feel. The Java API documentation for this class (see Resources) shows that most of the methods defined in this class are getter methods that return the colors and fonts used to draw the different widgets provided in the swing frame. However, the task of returning the value of these getter methods is not implemented directly in this class, but is delegated to another class, which is called a topic (theme). The only purpose of a theme is to provide values for the colors and fonts you want to use.
Metal look and feel use an pluggable theme architecture. This look and feel itself (Javax.swing.plaf.metal.MetalLookAndFeel) defines the appearance of widgets and their reactions to user interaction, while themes define the colors and fonts that should be used when drawing widgets. You can define a new topic by creating a new class that inherits Javax.swing.plaf.metal.MetalTheme.