Hello,
Scott Violet (Sun) has written up a story titled
"The Synth Look and Feel: A Skinnable Look and Feel
for 1.5" that shows you how you can use XML to style
your Java Swing UIs that use Java 1.5 and greater.
Scott writes:
Here's a portion of the code that draws this border:
public void paintBorder(Component c, Graphics g, int
x, int y, int width, int height) {
g.drawImage(images[0], x, y, null);
g.drawImage(images[2], x + width -
insets.right, y, null);
g.drawImage(images[4], x + width -
insets.right,
y + height - insets.bottom, null);
g.drawImage(images[6], x, y + height -
insets.bottom, null);
...
}
Writing code like this is fun the first couple of
times, but it soon becomes obvious there needs to be a
better way to provide a custom image-based look and
feel without writing code.
...
For the anxious, here's a quick example. The
following XML code, taken from example1.xml, defines a
style named textfield and binds it to all text fields
in Synth. The result is that text fields look like the
one above.
<synth>
<style id="textfield">
<state>
<color value="white" 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>
Full story @
http://www.javadesktop.org/articles/synth
and
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/doc-files/synthFileFormat.html
- Gerald
-------------------
Gerald Bauer
Open XUL Alliance - A Rich Internet For Everyone
http://xul.sourceforge.net
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
xul-announce mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xul-announce