本文主要是介绍Java swing更改全局字体,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
这段代码在jframe显示前调用,比如main方法开始就调用:
public static void setUIFont() {Font f = new Font("宋体",Font.PLAIN,18);String names[]={ "Label", "CheckBox", "PopupMenu","MenuItem", "CheckBoxMenuItem","JRadioButtonMenuItem","ComboBox", "Button", "Tree", "ScrollPane","TabbedPane", "EditorPane", "TitledBorder", "Menu", "TextArea","OptionPane", "MenuBar", "ToolBar", "ToggleButton", "ToolTip","ProgressBar", "TableHeader", "Panel", "List", "ColorChooser","PasswordField","TextField", "Table", "Label", "Viewport","RadioButtonMenuItem","RadioButton", "DesktopPane", "InternalFrame"}; for (String item : names) {UIManager.put(item+ ".font",f); } }
这篇关于Java swing更改全局字体的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!