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


import javax.swing.UIManager;

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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值