|
Helping ordinary people create extraordinary websites! |
Advanced SynthBy Michael Abernethy2005-04-16
More-Advanced Settings This section covers a couple of techniques that go beyond those you've seen in the login-screen example. You might find them useful in creating your own Synth looks. 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. Tutorial Pages: » Custom UIs are a Breeze with the Newest Swing Look and Feel » Beauty's Only Skin Deep » Synth Basics » Demo Application » Changing a Color and Font » Using Images » Handling Different States » Working with Custom Painters » More-Advanced Settings » Examining Synth Performance, Reliability, and Efficiency » Conclusion » Resources First published by IBM DeveloperWorks |
|