【Java】Java GUI改变界面风格
作者:互联网
✨UIManager
// Metal风格(默认)
String lookAndFeel ="javax.swing.plaf.metal.MetalLookAndFeel";
// Windows风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
// Windows Classic风格
String lookAndFeel ="com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
// Motif风格
String lookAndFeel ="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
// Mac风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.mac.MacLookAndFeel";
// GTK风格 (需要在相关的操作系统上方可实现)
String lookAndFeel ="com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
// 可跨平台的默认风格
String lookAndFeel =UIManager.getCrossPlatformLookAndFeelClassName();
// 当前系统的风格
String lookAndFeel =UIManager.getSystemLookAndFeelClassName();
选择一种界面风格后调用
!必须使用try - catch 环绕
try {
UIManager.setLookAndFeel(lookAndFeel);
} catch (Exception e) {
e.printStackTrace();
}
✨JFrame
JFrame.setDefaultLookAndFeelDecorated(true);
!需要写在调用JFrame及其子类构造方法之前
✨参考及引用
https://blog.csdn.net/u010995220/article/details/49847307
https://blog.csdn.net/evilcry2012/article/details/43669209
⭐转载请注明出处
本文作者:双份浓缩馥芮白
原文链接:https://www.cnblogs.com/Flat-White/p/14797612.html
版权所有,如需转载请注明出处。
标签:Java,String,sun,GUI,界面风格,lookAndFeel,swing,com,plaf 来源: https://www.cnblogs.com/Flat-White/p/14797612.html