Synth Look and Feel

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

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 Template:Javadoc:SEs.

History

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

Java upcoming Java SE 6 Update 10 release (which was called Consumer JRE by Sun) will use Nimbus, a cross-platform Look and Feel implemented with synth, as the default Look and Feel[1][2].

Architecture

Synth is a skinnable look and feel in which all painting is delegated to the components, without having to write any code (see Template:Javadoc:SE).

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.

<source lang="xml">
<synth>
 <style id="defaultStyle">
   
   <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>
</source>

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 Template:Javadoc:SE class):

<source lang="java">
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(new File("synthExample.xml").toURL());
UIManager.setLookAndFeel(laf);
</source>

See also

References

  1. [{{Expansion depth limit exceeded||}} "Welcome to the Java SE 6 Update N Early Access Program!"]. Sun Microsystems. {{Expansion depth limit exceeded||}}. Retrieved 2007-11-01. 
  2. Haase (May 2007). [{{Expansion depth limit exceeded||}} "Consumer JRE: Leaner, Meaner Java Technology"]. Sun Microsystems. {{Expansion depth limit exceeded||}}. Retrieved 2007-11-01. 

External links

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...