Java Reference
In-Depth Information
<style id="textfield">
<opaque value="true"/>
<state>
<color value="#C2E2CF" type="BACKGROUND"/>
<color value="#000000" type="TEXT_FOREGROUND"/>
</state>
<imagePainter method="textFieldBorder" path="text.png"
sourceInsets="3 3 3 3" paintCenter="false"/>
<insets top="3" left="3" bottom="3" right="3"/>
</style>
<bind style="textfield" type="region" key="TextField"/>
Adding a JTextField to the program in Listing 20-12 generates a screen similar to Figure 20-12.
When you resize the screen, the text field border grows. Technically speaking, a similar definition
would also work for a JTextArea , as there is no height restriction to the image being used here.
Figure 20-12. Using the custom text component border
Tip Much more is in store for the SynthLookAndFeel . In time, expect tools to help with the creation of
the XML configuration files. Also expect to be able to purchase libraries that let you just plug in complete look
and feel classes created with Synth. Be sure to explore SourceForge for just such a collection.
Summary
In this chapter, you explored the pluggable look and feel architecture of the Swing components.
Because all aspects of the Swing components are written in the Java programming language, if
you don't like a particular aspect of a component, you can simply change it. And changing it is
what this chapter showed you how to do.
First, you learned how to query for the preinstalled LookAndFeel classes and how to change
your current look and feel. Next, you learned how to customize the current look and feel by
modifying its UIDefaults through the UIManager . You saw how these default settings can imple-
ment the UIResource interface so that the settings change when the look and feel class changes.
In addition, you saw how these resources can implement the UIDefaults.LazyValue and
UIDefaults.ActiveValue interfaces for better use of resources. Moreover, you saw how client
 
Search WWH ::




Custom Search