哪位大吓可以说一下.java换皮肤怎么换呀..我都死了...
就是像千千静听一换皮肤呀..
最好给个实例..不胜感激!!!!

解决方案 »

  1.   

    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.synth
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/package-summary.html
      

  2.   

    给你个例子,没有编译过,你试试吧:
    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);
       }
      

  3.   

    哦,那个TestSwing.this 应该写成 Test.this, 再引用几个包
      

  4.   

    把风格定义在一个类里面,然后遍历要改变外观的控件(方便的话放在一个static的vector里,方便遍历)。用instanceof找到各个类型,然后根据类型更换类型外观
      

  5.   

    jdk1.5的例子程序里有好几个都有换肤的例子,如swingset2