Java Swing Font Set initGlobalFontSetting()

Here you can find the source of initGlobalFontSetting()

Description

init Global Font Setting

License

Open Source License

Declaration

public static void initGlobalFontSetting() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Font;

import java.util.Enumeration;

import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;

public class Main {
    public static void initGlobalFontSetting(Font font) {
        FontUIResource fontRes = new javax.swing.plaf.FontUIResource(font);
        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof javax.swing.plaf.FontUIResource)
                UIManager.put(key, fontRes);
        }//from   w w  w  .  ja v  a 2s  . c o  m
    }

    public static void initGlobalFontSetting() {
        Font font = new Font("SansSerif", Font.TRUETYPE_FONT, 12);
        FontUIResource fontRes = new javax.swing.plaf.FontUIResource(font);
        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof javax.swing.plaf.FontUIResource)
                UIManager.put(key, fontRes);
        }
    }
}

Related

  1. getCharsWidth(Font font, char[] chars, int offset, int length)
  2. getFont(AttributeSet a)
  3. increaseLabelFont(JLabel label, int offset)
  4. setAntiAlisingFont()
  5. setBorderFromFont(JComponent c)
  6. setComponentsFont(Container container, Font font)
  7. setDefaultFont(final Font font)