换皮肤!!! 哪位大吓可以说一下.java换皮肤怎么换呀..我都死了...就是像千千静听一换皮肤呀..最好给个实例..不胜感激!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Synth 外观,它是 Java 5.0 中为 Swing 引入的最新内容。通过为 Java UI 编程引入“皮肤”的概念,Synth 使开发人员可以为应用程序创建和部署定制的外观。//下面的Java代码为GUI倒入了一个look_1.xml皮肤SynthLookAndFeel synth = new SynthLookAndFeel();synth.load(SynthFrame.class.getResourceAsStream("look_1.xml"), SynthFrame.class);UIManager.setLookAndFeel(synth);对于 Synth,最重要的是要理解它是 XML 代码,而不是 Java 代码。例如下面定义一个按钮:<style id="button">//...这里描述按钮的颜色、字体、边框等属性</style><bind style="button" type="region" key="JButton"/>javax.swing.plaf.synthhttp://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/package-summary.html 给你个例子,没有编译过,你试试吧:class Test extends JFrame{ public Test(){ Container cp = getContentPane(); cp.setLayout(new FlowLayout()); JButton motif = new JButton("Motif"),windows = new JButton("Windows"); motif.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ try{ UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); SwingUtilities.updateComponentTreeUI(TestSwing.this); } catch(Exception exception){exception.printStackTrace();} } }); windows.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ try{ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); SwingUtilities.updateComponentTreeUI(TestSwing.this); } catch(Exception exception){exception.printStackTrace();} } }); cp.add(motif); cp.add(windows); } public static void main(String[] args){ Test test = new Test(); test.setSize(300,200); test.setVisible(true); } 哦,那个TestSwing.this 应该写成 Test.this, 再引用几个包 把风格定义在一个类里面,然后遍历要改变外观的控件(方便的话放在一个static的vector里,方便遍历)。用instanceof找到各个类型,然后根据类型更换类型外观 jdk1.5的例子程序里有好几个都有换肤的例子,如swingset2 java认证的问题 请教~ 我自编了个小程序,但在界面处理上不爽,我想JPanel周围出现立体凹痕,并且,三个slider竖排,求助 请分析一下程序的运行结果 新手做的小记事本,,,,处理事件那有点问题,,帮忙看看吧,,,很急呀!!!! 如何调用这个类中的连接方法? 请问在GUI编程中调用另一个GUI源程序 Java类加载 java中,用于线程控制的wait() 新手上路,来人指点! Validator能否实现javascript的confirm的功能 没分了,只能谢谢!怎么运行winform? 请问静态变量声明时未被赋值会被分配空间吗?
SynthLookAndFeel synth = new SynthLookAndFeel();
synth.load(SynthFrame.class.getResourceAsStream("look_1.xml"), SynthFrame.class);
UIManager.setLookAndFeel(synth);对于 Synth,最重要的是要理解它是 XML 代码,而不是 Java 代码。
例如下面定义一个按钮:
<style id="button">
//...这里描述按钮的颜色、字体、边框等属性
</style>
<bind style="button" type="region" key="JButton"/>javax.swing.plaf.synth
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/package-summary.html
class Test extends JFrame{
public Test(){
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
JButton motif = new JButton("Motif"),windows = new JButton("Windows");
motif.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(TestSwing.this);
}
catch(Exception exception){exception.printStackTrace();}
}
});
windows.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(TestSwing.this);
}
catch(Exception exception){exception.printStackTrace();}
}
});
cp.add(motif);
cp.add(windows);
}
public static void main(String[] args){
Test test = new Test();
test.setSize(300,200);
test.setVisible(true);
}