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

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

效果展示

相关推荐
随遇而安zx几秒前
【多线程】---JMM 与 volatile 深度解析
java·多线程
邪修king27 分钟前
Re:Linux系统篇(十九):进程篇(八): 进程等待详解:wait/waitpid,僵尸进程到底该如何回收
java·开发语言
啵啵啵鱼39 分钟前
DS-顺序表
java·数据结构·笔记·后端·链表·obsidian
TinyMemory1 小时前
Java 面向对象核心入门(七):方法重载 Overload,同一个方法名能干不一样的活
java·面向对象·overload·方法重载
开开心心就好1 小时前
免费刷题软件推荐,支持导入题库自动判题
网络·网络协议·tcp/ip·jupyter·智能手机·电脑·idea
吴声子夜歌1 小时前
Java扩展——OkHttp
java·开发语言·okhttp
卓怡学长1 小时前
w210基于springboot反诈平台设计与实现
java·spring boot·spring·intellij-idea
萧瑟余晖2 小时前
Java深入解析篇六十一之编译器API(javax.tools)详解
java·开发语言
码云数智-园园2 小时前
C++ STL 容器怎么选?vector、list、map、unordered_map 优缺点对比
java·开发语言