Misplaced Pages

Synth Look and Feel

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Skinnable Java look and feel
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
The topic of this article may not meet Misplaced Pages's general notability guideline. Please help to demonstrate the notability of the topic by citing reliable secondary sources that are independent of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the article is likely to be merged, redirected, or deleted.
Find sources: "Synth Look and Feel" – news · newspapers · books · scholar · JSTOR (April 2011) (Learn how and when to remove this message)
This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources.
Find sources: "Synth Look and Feel" – news · newspapers · books · scholar · JSTOR (April 2011) (Learn how and when to remove this message)
(Learn how and when to remove this message)

synth is a skinnable Java look and feel, which is configured with an XML property file.

According to Sun, goals for synth were:

  • Enable to create custom look without writing any code.
  • Allow appearance to be configured from images.
  • Provide the ability to customize the look of a component based on its named properties.
  • Provide a centralized point for overriding the look of all components.
  • Enable custom rendering based on images, or user-defined SynthPainters.

History

synth is available beginning with version J2SE 5.0 of Java (see Java version history).

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.

Architecture

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).

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.

Example

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);

See also

References

  1. Scott Violet (2004-03-26). "The Synth Look and Feel". javadesktop.org. Retrieved 2013-03-09. Synth is new and provides for the description of the look and feel through an external XML file.
  2. "Taming Tiger: Ocean and Synth meet Metal". IBM. 2004-10-19. Retrieved 2012-11-13. Synth is new and provides for the description of the look and feel through an external XML file.
  3. "Nimbus Look and Feel (The Java Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)". Sun Microsystems. Retrieved 2010-07-01.
  4. "Advanced Synth". IBM. 2005-02-01. Retrieved 2012-11-13. Synth lets developers rapidly create and deploy custom looks for an application by introducing the concept of a "skin" to Java UI programming

External links

Java desktop
APIs
Deprecated APIs
Open-source


Stub icon

This computer-library-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: