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

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

效果展示

相关推荐
wifi___2 小时前
全局异常处理的原理
java·开发语言
2601_963870206 小时前
【计算机毕业设计】基于Spring Boot的专科医院医疗管理系统
java·spring boot·课程设计
Bingo_BIG6 小时前
Java Spring 批量修改,实体、接口、方法的定义
java·spring
画中有画7 小时前
软件架构中质量属性(性能、安全、可扩展性)的权衡设计
java·运维·安全
Shaoxi Zhang7 小时前
JAVA学习笔记035——对象和JSON格式
java·笔记·学习
赵丙双7 小时前
CountDownLatch 源码分析
java·aqs·countdownlatch
Oll Correct7 小时前
Adobe illustrator 案例六:手枪图标绘制
笔记·ui·adobe·illustrator
余额瞒着我当琳7 小时前
C++--深拷贝三件套 + swap + 写时拷贝 + vector 扩容 + reserve
java·开发语言·c++
thefool1122667 小时前
翻转二叉树
java
喜欢打篮球的普通人8 小时前
LLVM Backend Lowering 从入门到实战:把 IR 变成机器码的完整链路
android·java·数据库