Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Font;

import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;

import javax.swing.UIDefaults;
import javax.swing.UIManager;

public class Main {
    /**
     * magnify the all fonts in swing.
     * 
     * @param mag
     *            magnify parameter <br/> mag > 1. : large <br/> mag < 1. :
     *            small
     */
    public static void magnifyAllFont(float mag) {
        List history = new LinkedList();
        UIDefaults defaults = UIManager.getDefaults();
        Enumeration it = defaults.keys();
        while (it.hasMoreElements()) {
            Object key = it.nextElement();
            Object a = defaults.get(key);
            if (a instanceof Font) {
                if (history.contains(a))
                    continue;
                Font font = (Font) a;
                font = font.deriveFont(font.getSize2D() * mag);
                defaults.put(key, font);
                history.add(font);
            }
        }
    }
}