SWing UIManager 设置主题/获取所有UIManager设置

public class SWingUtil {

    public static Map<String, String> themeMap;
    static {
        //主题名 - className
        themeMap = new LinkedHashMap<>();
        //swing默认主题
        themeMap.put("Metal","javax.swing.plaf.metal.MetalLookAndFeel");
        themeMap.put("Windows","com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        themeMap.put("Windows Classic","com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
        themeMap.put("Motif","com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        themeMap.put("当前系统",UIManager.getSystemLookAndFeelClassName());
        themeMap.put("Flat Light(默认)","com.formdev.flatlaf.FlatLightLaf");
        themeMap.put("Flat dark","com.formdev.flatlaf.FlatDarkLaf");
        themeMap.put("Flat IntelliJ","com.formdev.flatlaf.FlatIntelliJLaf");
        themeMap.put("Flat Darcula","com.formdev.flatlaf.FlatDarculaLaf");

        // http://www.jtattoo.net/index.html
        themeMap.put("Tattoo01","com.jtattoo.plaf.acryl.AcrylLookAndFeel");
        themeMap.put("Tattoo02","com.jtattoo.plaf.aero.AeroLookAndFeel");
        themeMap.put("Tattoo03","com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
        themeMap.put("Tattoo04","com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");
        themeMap.put("Tattoo05","com.jtattoo.plaf.fast.FastLookAndFeel");
        themeMap.put("Tattoo06","com.jtattoo.plaf.hifi.HiFiLookAndFeel");
        themeMap.put("Tattoo07","com.jtattoo.plaf.mcwin.McWinLookAndFeel");
        themeMap.put("Tattoo08","com.jtattoo.plaf.mint.MintLookAndFeel");
        themeMap.put("Tattoo09","com.jtattoo.plaf.noire.NoireLookAndFeel");
        themeMap.put("Tattoo10","com.jtattoo.plaf.smart.SmartLookAndFeel");
        themeMap.put("Tattoo11","com.jtattoo.plaf.luna.LunaLookAndFeel");
        themeMap.put("Tattoo12","com.jtattoo.plaf.texture.TextureLookAndFeel");
    }
    public static void UnifiedStyle(){
        try {
            String lookAndFeel = getLookAndFeel(18);

            UIManager.setLookAndFeel(lookAndFeel);
            UIManager.put("TableHeader.font",new Font("微软雅黑", Font.PLAIN, 20));
            UIManager.put("InternalFrame.titleFont",new Font("微软雅黑", Font.PLAIN, 15));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getLookAndFeel(int index){

        int i = 0;
        for (String value : themeMap.values()) {
            if (i == index){
                return value;
            }
            i++;
        }
        return null;
    }

    public static void main(String[] args) {
//        FontUIResource fontRes = new FontUIResource(font);

        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()){
            Object key = keys.nextElement();
            Object value = UIManager.get(key);


//            if (value instanceof FontUIResource) {
//                UIManager.put(value,font);
//                System.out.println(key);
//            }
            System.out.println(key);
        }

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值