Advanced Synth
By Michael Abernethy2005-04-16
More-Advanced Settings
Painting non-Swing componentsBeing able to change the look of every Swing component is great, but Synth also needs to be able to change the look of other components -- ones developers have created to fill the gaps left by Swing. In such cases, the <bind> tag needs to change to reflect that a Swing component isn't being painted. The type attribute can have two values -- region if it is being mapped to a Swing component, and name if it is being mapped to a non-Swing component. So, changing the <bind> tag to <bind style="mystyle" type="name" key="Custom.*"/> will change every component whose class name starts with Custom (for example, CustomTextField or CustomLabel) to use the mystyle style.
Hierarchies of stylesBreaking from the KISS style of creating the XML file, you can also build a hierarchy of styles and apply them to components. Listing 9 should make this clear. Note that Synth uses the attribute that was defined last to render the component.
Listing 9. Example of hierarchies
<style id="base">The code in Listing 9 gives every component a black background with a font size of 14 except labels, which have a red background. By cloning the base style in sublevel, it copies the entire style. You can then override any specific properties that you need to.
<color value="BLACK" type="BACKGROUND"/>
<state>
<font size="14"/>
</state>
</style>
<bind style="base" type="region" key=".*"/>
<style id="sublevel" clone="base">
<color value="RED" type="BACKGROUND"/>
</style>
<bind style="sublevel" type="region" key="Label"/>
First published by IBM DeveloperWorks
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Advanced Synth"
You must be logged in to post a comment.
Link to This Tutorial Page!

