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); 
	}
}

你可能感兴趣的:(Swing,java,swing)