So far, all of Merlin's magic columns are new features of the Java 1.4 version, and this article is focused on the 1.4.2 version currently being tested. Sun thinks Windows ' Classic look is obsolete and no one is using motif-at least on the user's desktop. You'll find the new look of Windows and a new appearance called GTK + in the latest version of this standard Java platform, and the new Windows look like Windows xp,gtk+ uses the normal Linux desktop when users use Windows XP operating systems.
The swing architecture provides a pluggable façade framework. For example, the framework provides a standard way to make all component fonts 8-point bold Lucida without having to change all the tuning to create a component. All you need to do is insert a new setting into the skin, like magic, where all calls automatically pick up the changes. You can even change the overall style of the GUI by setting the appearance. Previously, J2SE 1.4 provided skin designs for platform-oriented UI, such as Microsoft Windows and Motif. It also offers a cross-platform UI, called metal, specifically for the Java platform, which looks all the same regardless of what desktop the user uses.
Change the appearance design
Before we examine the latest designs, let's show you how to change the look of a Java program, as shown in table 1:
Table 1: Finding all display modes
Import java.awt.*
Import javax.swing.*
public class start extends JFrame {
Public start () {
Set Defaultcloseoperation (Exit_on_close);
Container C = Getcontentpane ();
JButton button = new JButton ("Hello");
C.add (button, borderlayout.center);
SetSize (100, 50);
Show ();
}
public static void Main (string[] args) {
try {
Uimanager.setlookandfeel (
Uimanager.getcrossplatfor Mlookandfeelclassname ());
//uimanager.getsystemlookandfeelclassname ());
} catch (Exception e) {
}
new Start ();
}
}
The Uimanager Setlookandfeel () call allows you to enter a class name that is fully standardized in the new design. You no longer have to worry about which class name applies to the cross-platform metal UI (Javax.swing.plaf.metal.MetalLookAndFeel), you only need to use Getcrossplatformlookandfeelclassname () method to ask the system for a name. On the other hand, Getsystemlookandfeelclassname () returns the UI class name dedicated to the user's desktop. If the user runs the program on a Windows device, he will get the Windows UI through the Com.sun.java.swing.plaf.windows.WindowsLookAndFeel class. On UNIX devices, the MOTIF/CDE interface or Com.sun.java.swing.plaf.motif.MotifLookAndFeel class is returned. J2SE 1.4.2 provides a new GTK + appearance, but does not return a system appearance class as a UNIX machine. This situation will be improved in the J2SE 1.5 version. Figure 1 shows the output appearance of the start program when running on a Windows 2000 device:
Figure 1: Cross platform UI