Java Swing Font Set setUIFont(Font fon)

Here you can find the source of setUIFont(Font fon)

Description

Sets the default Font for the current UIManager

License

LGPL

Parameter

Parameter Description
fon the new Font

Declaration

public static void setUIFont(Font fon) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;

import java.util.Enumeration;

public class Main {
    /**//from  www  .  j  a v a 2  s . co  m
     * Sets the default Font for the current UIManager
     *
     * @param fon the new Font
     */
    public static void setUIFont(Font fon) {
        FontUIResource f = new FontUIResource(fon);
        Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value != null && value instanceof javax.swing.plaf.FontUIResource) {
                UIManager.put(key, f);
            }
        }
        for (Window w : Window.getWindows()) {
            SwingUtilities.updateComponentTreeUI(w);
        }
    }
}

Related

  1. setTitleLabelFont(JLabel label)
  2. setUIDefaultFont()
  3. setUIFont(final Font font)
  4. setUIFont(final Font font)
  5. setUIFont(Font f)
  6. setUIFont(FontUIResource f)
  7. setUIFont(FontUIResource f)
  8. setUIFont(FontUIResource f)
  9. setUIFont(FontUIResource f)