javaswinglook-and-feelsynth

Synth Look and Feel - Is it possible to write xml to do both general and specified customization?


Synth provides a way to use xml to customize java swing look and feel. From my understanding, it could do general customization. For example:

So does synth xml support this (and how)? thanks!


Solution

  • Synth L&F supports also name-binding.

    Here is the XML example:

    <style id="defaultHeaderPanel">
        <insets top="4" left="4" bottom="4" right="4"/>
        <state>
            <opaque value="true" />
            <color type="BACKGROUND" value="#00538c"/>
        </state>
    </style>
    <bind style="defaultHeaderPanel" type="name" key="DefaultHeaderPanel" />
    

    To use this style you need to call the method setName(String) with the key of your bind XML element.

    For example:

    public class HeaderPanel extends JPanel {
    
        public HeaderPanel() {
            setName("DefaultHeaderPanel"); // assign style name
        }
    }