【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.apple.laf.AquaLookAndFeel";
// 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构造方法之前
✨JDialog
JDialog.setDefaultLookAndFeelDecorated(true);
!需要写在调用JDialog构造方法之前
✨参考及引用
https://blog.csdn.net/u010995220/article/details/49847307
https://blog.csdn.net/evilcry2012/article/details/43669209
https://blog.csdn.net/dyhml/article/details/291182
⭐转载请注明出处
本文作者:双份浓缩馥芮白
原文链接:https://www.cnblogs.com/Flat-White/p/14456238.html
版权所有,如需转载请注明出处。