Specifying Look and Feel

Swing graphical user interfaces (GUIs) takes Java look and feel by default. However, it is possible to specify a windowing system look and feel.

Look and feel is set by the javax.swing.UIManager.setLookAndFeel method. This method has one parameter, the name of the class that determines look and feel. These classes are not part of the Java language itself, but rather classes within a package
(com.sun.java.swing) supplied by the Java Software Development Kit (SDK). The classes are as follows com.sun.java.swing.plaf.windows.WindowsLookAndFeel for Windows (32 bit only) operating systems

com.sun.java.swing.plaf.motif.MotifLookAndFeel for CDE/Motif look and feel on Sun platforms

The setLookAndFeel method must be invoked within a try catch block. For example, the following code fragment will create a Windows look and feel:

Try
{ UIManager.setLookAndFeel(''com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception e) { }

No comments:

Post a Comment