java Swing UI设置统一字体大小

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

java 复制代码
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);
        }
    }

一定要在组件前调用,否则看不到效果

效果展示

相关推荐
\光辉岁月/5 小时前
3.java运算符
java·开发语言
mjhcsp5 小时前
DeepSeek V4.1 Flash 批量处理效能实测
java·前端·数据库
海绵宝宝转agent6 小时前
操作系统八股开源笔记分享
java·面试
殷色玫瑰6 小时前
C++ string类详解:常用接口、字符串操作与模拟实现
java·linux·c语言·开发语言·数据结构·c++
CHEEVEN_QY6 小时前
新能源汽车电池托盘FSW量产的工艺稳定性控制
java·前端·汽车
惊讶的猫6 小时前
MCP-server
java
传奇开心果编程6 小时前
【ArkUI进阶练中学】第12课:应用架构演进与遗留系统迁移
学习·ui·华为·harmonyos
ZealSinger6 小时前
Boot4升级PostConstruct不跑了
java·spring boot·spring·升级迁移
Code_Solitude7 小时前
C语言:关于二维数组的作业总结
java·c语言·前端