synth is a skinnable Java look and feel, which is configured with an XML property file.[1]
According to Sun, goals for synth were:
SynthPainter
s.synth is available beginning with version J2SE 5.0 of Java (see Java version history).[2]
Java SE 6 Update 10 release and newer contain Nimbus, a cross-platform Look and Feel implemented with Synth. However, for backwards compatibility, Metal is still the default Swing look and feel.[3]
Synth is a skinnable look and feel in which all painting is delegated to the components, without having to write any code (see Synth Look and Feel
).[4]
However synth does not provide a default look, and components that are not defined in the synth XML file will not be painted. It is however possible to assign a default style to all other widgets, and customize styles for some specific widgets only.
The following XML declaration defines a style named textfield and binds it to all text fields. The defaultStyle allows to set a default font, foreground and background colors to all other widgets.
<synth>
<style id="defaultStyle">
<font name="Verdana" size="16"/>
<state>
<color value="WHITE" type="BACKGROUND"/>
<color value="BLACK" type="FOREGROUND"/>
</state>
</style>
<bind style="defaultStyle" type="region" key=".*"/>
<style id="textfield">
<state>
<color value="yellow" type="BACKGROUND"/>
</state>
<imagePainter method="textFieldBorder" path="textfieldborder.png"
sourceInsets="5 6 6 7" paintCenter="false"/>
<insets top="5" left="6" bottom="6" right="7"/>
</style>
<bind style="textfield" type="region" key="TextField"/>
</synth>
Supposing that the XML declaration is defined in a file named synthExample.xml, the following code loads the XML definition file and sets the current look and feel to synth (loading a synth Look and Feel is done using the load method of the SynthLookAndFeel
class):
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(new File("synthExample.xml").toURI().toURL());
UIManager.setLookAndFeel(laf);
Synth is new and provides for the description of the look and feel through an external XML file.
Synth is new and provides for the description of the look and feel through an external XML file.
Synth lets developers rapidly create and deploy custom looks for an application by introducing the concept of a "skin" to Java UI programming
Synth Look and Feel
API documentation