In this section, we’ll look at different ways that you can change the way components in your application appear. We’ll start with the simplest approach—making property changes on a per-component basis—and work our way through several increasingly powerful (and complicated) strategies. In the last section, we’ll show you how to build your own L&F from the ground up.
This is the most obvious way to change the look of a component,
and it’s certainly not new to Swing. At the very top of the Java
java.awt.Component defines a number of
fundamental properties, including
font. If you want to change the way a
specific component looks, you can always just change the value of
these properties, or any of the others defined by the specific
components you are using. As we said, this is nothing new to the Swing
PLAF architecture, but we don’t want to lose sight of the fact that
you can still make many changes in this way.
Bear in mind that platform-specific L&F constraints on the rendering of certain components may prevent some property changes from being honored. For example, Mac buttons are always the same color.
Modifying component properties lets you customize individual components. But what if you want to make more global changes? What if you want to change things that aren’t exposed as component properties?
This is where
UIResources come into play. There ...