编写一个遍历组件设置字体大小的方法
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", "PanelList", "ColorChooser", "PasswordField", "TextField","TableLabel", "Viewport", "RadioButtonMenuItem", "RadioButton", "DesktopPane", "InternalFrame"};for (String item : names) {UIManager.put(item + ".font", f);}}
一定要在组件前调用,否则看不到效果
效果展示