hz_chenwenbiao 发表于 2013-1-28 12:39:48

JAVA 桌面程序的外观风格+主题场景 (更新)(转)

加入下面程度,可以更改JAVA桌面应用程序的风格:

int i = 0;try {//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");//JAVA默认的跨平台外观风格//UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");//Nimbus风格,新出来的外观,JDK 6 Update10 版本开始出现//UIManager.setLookAndFeel("com.nilo.plaf.nimrod.NimRODLookAndFeel");//Nimrod风格(需要导入.jar包,nimrodlf-1.0e.jar,需要请留言)//UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");//Liquid风格(需要导入.jar包,liquidlnf.jar,需要请留言)UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());//当前系统风格//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");//Motif风格,外观接近windows经典,但宽宽大大,而且不是黑灰主色,而是蓝黑//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());//跨平台的Java界面风格,不太明白这种说法//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");//windows风格//UIManager.setLookAndFeel("com.apple.mrj.swing.MacLookAndFeel");//缺少类//UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");//缺少类switch (i) {                case 0:                  MetalLookAndFeel.setCurrentTheme(new OceanTheme());//海洋场景                  i = 1;                  break;                case 1:                  MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());//默认场景                  i = 0;                  break;}//设置主题场景SwingUtilities.updateComponentTreeUI(this);//更新外观,如果以上代码直接放在main中,此行可以不加} catch (Exception e) {e.printStackTrace();}
页: [1]
查看完整版本: JAVA 桌面程序的外观风格+主题场景 (更新)(转)