UIManager.setLookAndFeel(“ com.sun.java.swing.plaf.windows.WindowsLookAndFeel ”);//windows默认
UIManager.put("MenuBar.font", font);//给控件设置字体
static Object | put (Object key, Object value) |
public static void setLookAndFeel(String className, java.awt.Component c) {
try {
UIManager.setLookAndFeel(className);
SwingUtilities.updateComponentTreeUI(c);//注意这行
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null,
"不好意思,setLookAndFeel时出错了:( Errormsg:" + ex,
"setLookAndFeel",
JOptionPane.INFORMATION_MESSAGE);
}
本文介绍如何使用Java Swing更改应用程序的外观和感觉,包括设置LookAndFeel和字体等操作,并提供了异常处理的方法。

861

被折叠的 条评论
为什么被折叠?



