Java Reference
In-Depth Information
CHAPTER 20
■ ■ ■
The Pluggable Look and
Feel Architecture
I n Chapter 19, you examined Swing's drag-and-drop support. In this chapter, you will take an
in-depth look at the pluggable look and feel (PLAF) architecture that's available when you're
working with the Swing component library.
All aspects of the Swing components are Java-based. Therefore, no native source code
exists, as there is with the AWT component set. If you don't like the way the components are,
you can change them, and you often have many ways to do so.
The abstract LookAndFeel class is the root class for a specific look and feel. Each one of the
installable look and feel classes, as they're described by the UIManager.LookAndFeelInfo class,
must be a subclass of the LookAndFeel class. The LookAndFeel subclass describes the default
appearance of Swing components for that specific look and feel.
The set of currently installed look and feel classes is provided by the UIManager class, which
also manages the default display properties of all the components for a specific LookAndFeel .
These display properties are managed within a special UIDefaults hash table. The display prop-
erties are either tagged with the empty UIResource interface or are UI delegates and therefore a
subclass of the ComponentUI class. These properties can be stored as either UIDefaults.LazyValue
objects or UIDefaults.ActiveValue objects, depending on their usage.
LookAndFeel Class
Implementations of the abstract LookAndFeel class describe how each of the Swing components
will appear and how the user will interact with them. Each component's appearance is controlled
by a UI delegate, which serves as both the view and the controller in the MVC architecture.
Each of the predefined look and feel classes is contained within its own package, along with its
associated UI delegate classes. When configuring the current look and feel, you can use one of
the predefined look and feel classes or create your own. When you create your own look and
feel, you can build on an existing look and feel, such as the BasicLookAndFeel class and its UI
delegates, instead of creating all the UI delegates from scratch. Figure 20-1 shows the class
hierarchy of the predefined look and feel classes.
741
Search WWH ::




Custom Search