Synth Look and Feel
Encyclopedia
synth is a skinnable Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 look and feel, which is configured with an XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

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

History

synth is available beginning with version J2SE 5.0 of Java (see Java version history
Java version history
The Java language has undergone several changes since JDK 1.0 as well as numerous additions of classes and packages to the standard library. Since J2SE 1.4, the evolution of the Java language has been governed by the Java Community Process , which uses Java Specification Requests to propose and...

).

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

However synth does not provide a default look, and components that are not defined in the synth XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 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.









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 class):

SynthLookAndFeel laf = new SynthLookAndFeel;
laf.load(new File("synthExample.xml").toURL);
UIManager.setLookAndFeel(laf);

See also

  • Swing
    Swing (Java)
    Swing is the primary Java GUI widget toolkit. It is part of Oracle's Java Foundation Classes — an API for providing a graphical user interface for Java programs....

    , the standard cross-platform widget toolkit
    Widget toolkit
    In computing, a widget toolkit, widget library, or GUI toolkit is a set of widgets for use in designing applications with graphical user interfaces...

     for Java
  • Pluggable look and feel
    Pluggable look and feel
    Pluggable look and feel is a mechanism used in the Java Swing widget toolkit allowing to change the look and feel of the graphical user interface at runtime....


External links

API documentation
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK