style id="button"
state
imagePainter method="buttonBackground" path="images/1_On.gif"
sourceInsets="9 10 9 12" paintCenter="true" stretch="true"/
insets top="9" left="10" bottom="9" right="12"/
font name="Aharoni" size="16"/
color type="TEXT_FOREGROUND" value="#FFFFFF"/
/state
state value="MOUSE_OVER"
imagePainter method="buttonBackground" path="images/1_Down.gif"
sourceInsets="9 10 9 12" paintCenter="true" stretch="true"/
insets top="9" left="10" bottom="9" right="12"/
color type="TEXT_FOREGROUND" value="#FFFFFF"/
/state
state value="PRESSED"
imagePainter method="buttonBackground" path="images/1_Off.gif"
sourceInsets="10 12 8 9" paintCenter="true" stretch="true"/
insets top="10" left="12" bottom="8" right="9"/
color type="TEXT_FOREGROUND" value="#FFFFFF"/
/state
property key="Button.margin" type="insets" value="0 0 0 0"/
/style
bind style="button" type="region" key="Button"/
/synth
5. 在Application1.Java文件的头部加入以下语句:
import javax.swing.plaf.synth.SynthLookAndFeel;
6. 对public void run()函数做如下的修改:
public void run() {
try {
//添加以下3个语句
SynthLookAndFeel synth = new SynthLookAndFeel();
synth.load(Application1.class.getResourceAsStream("demo.xml"),Application1.class);
UIManager.setLookAndFeel(synth);
/*原先的语句
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
*/
}
7. 编译运行,便可看到结果了。
8. 其它控件的使用方法类似。