Java Reference
In-Depth Information
Figure 20-1.
LookAndFeel class hierarchy diagram
Each of the look and feel classes has six properties, as shown in Table 20-1.
Table 20-1.
LookAndFeel Properties
Property Name
Data Type
Access
defaults
UIDefaults
Read-only
description
String
Read-only
ID
String
Read-only
name
String
Read-only
nativeLookAndFeel
boolean
Read-only
supportedLookAndFeel
boolean
Read-only
These properties are all read-only and mostly describe the look and feel. The
defaults
property is slightly different, though. Once you get its
UIDefaults
value, you can then modify its
state directly through its own methods. In addition, the
UIDefaults
for a
LookAndFeel
can be
directly accessed and modified through the
UIManager
class.
The
nativeLookAndFeel
property enables you to determine if a particular look and feel
implementation is the native look and feel for the user's operating system. For instance, the
WindowsLookAndFeel
is native to any system running one of the Microsoft Windows operating
systems. The
supportedLookAndFeel
property tells you if a particular look and feel implementa-
tion can be used. With the
WindowsLookAndFeel
implementation, this particular look and feel
class is supported only if the current operating system is Microsoft Windows. Where available,
the
MacLookAndFeel
implementation is supported only on MacOS computers.
MotifLookAndFeel
and
MetalLookAndFeel
are native look and feel classes that are not locked to a particular oper-
ating system.
Listing the Installed Look and Feel Classes
To discover which look and feel classes are installed in your current environment, ask the
UIManager
, as shown in Listing 20-1. The
UIManager
has a
UIManager.LookAndFeelInfo[]
getInstalledLookAndFeels()
method that returns an array of objects providing the textual
name (
public String getName()
) and class name (
public String getClassName()
) for all the
installed look and feel classes.