Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Enumeration;

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

public class Main {
    /**
     * Code from http://stackoverflow.com/questions/1236231/managing-swing-ui-default-font-sizes-without-quaqua
     * @param fontSize
     */
    public static void changeDefaultFontSize(int fontSize) {
        UIDefaults defaults = UIManager.getDefaults();
        // UIDefaults defaults = UIManager.getLookAndFeelDefaults();
        Enumeration<Object> keys = defaults.keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            if ((key instanceof String) && (((String) key).endsWith(".font"))) {
                FontUIResource font = (FontUIResource) UIManager.get(key);
                defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
            }
        }
    }
}