Java Reference
In-Depth Information
GTK is a PLAF that implements the look and feel of the X Window-oriented
GTKwidgettoolkit.It'slocatedinthe com.sun.java.swing.plaf.gtk
package and its main class is GTKLookAndFeel .
Motif is a PLAF that implements the look and feel of the X Window-oriented
Motif widget toolkit. It's located in the
com.sun.java.swing.plaf.motif package and its main class is Mo-
tifLookAndFeel .
Windows isaPLAFthatimplementsthelookandfeelofthecurrentWindows
platform (e.g.,classic Windows,WindowsXP,orWindowsVista).It'slocated
inthe com.sun.java.swing.plaf.windows packageanditsmainclass
is WindowsLookAndFeel .
The main PLAF classes ultimately extend the abstract
javax.swing.LookAndFeel class.Also,forlicensingreasons,Swingletsyouuse
the GTK PLAF only on X Window-based platforms, and lets you use the Windows
PLAF only on a Windows platform.
The javax.swing.UIManager class provides the void
setLookAndFeel(String className) class method for installing a look and
feel prior to displaying the GUI. This method throws one of
java.lang.ClassNotFoundException when the LookAndFeel subclass
named by className cannot be found,
java.lang.InstantiationException whenanewinstanceoftheclasscould
not be created reflectively, java.lang.IllegalAccessException when the
class or initializer isn't accessible,
javax.swing.UnsupportedLookAndFeelException when the PLAF won't
run on the current platform, and java.lang.ClassCastException when
className identifies a class that doesn't extend LookAndFeel .
ThefollowingexampleattemptstoinstallNimbusasthecurrentlookandfeelbefore
creating the GUI:
try
{
UIMan-
ager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
new GUI();
}
catch (Exception e)
Search WWH ::




Custom Search