本文转自:披Zhe羊皮De狼,原文地址:http://blog.csdn.net/u010995220/article/details/49847307
- javax.swing.UIManager类
- LookAndFeel抽象类
Sun提供了三个LookAndFeel子类:javax.swing.plaf.metal.MetalLookAndFeel(Metal样式)、com.sun.java.swing.plaf.motif.MotifLookAndFeel(Motif样式)、com.sun.java.swing.plaf.windows.WindowsLookAndFeel(Windows样式)。
String lookAndFeel ="javax.swing.plaf.metal.MetalLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
2、Windows风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
3、Windows Classic风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
4、Motif风格
String lookAndFeel ="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
5、Mac风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.mac.MacLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
6、GTK风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
7、可跨平台的默认风格
String lookAndFeel =UIManager.getCrossPlatformLookAndFeelClassName();
UIManager.setLookAndFeel(lookAndFeel);
8、当前系统的风格
String lookAndFeel =UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(lookAndFeel);
- Java中的几种LookandFeel(此部分代码在main方法打开GUI界面之前实现)
String lookAndFeel ="javax.swing.plaf.metal.MetalLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
2、Windows风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
3、Windows Classic风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
4、Motif风格
String lookAndFeel ="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
5、Mac风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.mac.MacLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
6、GTK风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);
7、可跨平台的默认风格
String lookAndFeel =UIManager.getCrossPlatformLookAndFeelClassName();
UIManager.setLookAndFeel(lookAndFeel);
8、当前系统的风格
String lookAndFeel =UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(lookAndFeel);
- 一个实例
2、若是改变某个面板的观感,则代码为:
UIManager.setLookAndFeel(观感名);
SwingUtilities.updateComponentTreeUI(面板引用);
以上代码必须能够被捕获异常,否则报错。
非常感谢原文作者,亲测有效!