编写一个遍历组件设置字体大小方法

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

一定要在组件调用,否则看不到效果在这里插入图片描述

效果展示

在这里插入图片描述

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注