Integrate Your UI Class into Synth Look And Feel
Several years ago, when we talk about designing look and feel, we know it is about implementing different UI classes for different components.
Today since we are using JRE5 or above, we can use Synth look and feel, which
allow us to customize the look and feel by writing an XML file. Synth look and
feel provides some XML elements to define the painters for rendering the swing
components, it even allow us the write our own painter class and integrate into
the look and feel (using the painter element in XML).
It is true that we can use painters to draw anything we need on the component,
but can we control the component's behavior as well? In the pass, we can implement
a new UI class for the component to provide new behavior, and specify the UI
class in this way:
It sets the class com.easynth.test.lnf.EaSynthComboBoxUI
as JComboBox component's UI cass, But now we are using Synth look and feel,
can we still use the UI class?
Fortunately the answer is positive, by using the defaultsProperty
element, we can integrate our own UI class into Synth look and feel. Here is
<object id="EaSynth.ComboBox.UI" class="java.lang.String">
<defaultsProperty key="ComboBoxUI" type="idref" value="EaSynth.ComboBox.UI"/>
It is a snippet of the XML file which customize the whole look and feel. We
use the defaultsProperty element to set the UI class name of
JComboBox component, thus our new UI class is integrated into Synth look and