Java Swing Font Set setUIFont(javax.swing.plaf.FontUIResource f)

Here you can find the source of setUIFont(javax.swing.plaf.FontUIResource f)

Description

Forces a default Font for all components of actual JFrame.

License

Open Source License

Parameter

Parameter Description
a Font for all components of actual JFrame.

Declaration

public static void setUIFont(javax.swing.plaf.FontUIResource f) 

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 {
    /**// w  w  w .  j av  a 2s  . c  o m
     * Forces a default Font for all components of actual JFrame.
     * 
     * @param a
     *            Font for all components of actual JFrame.
     */
    public static void setUIFont(javax.swing.plaf.FontUIResource f) {
        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource) {
                FontUIResource orig = (FontUIResource) value;
                Font font = new Font(f.getFontName(), orig.getStyle(), f.getSize());
                UIManager.put(key, new FontUIResource(font));
            }
        }
    }
}

Related

  1. setUIFont(FontUIResource f)
  2. setUIFont(FontUIResource f)
  3. setUIFont(FontUIResource f)
  4. setUIFont(FontUIResource f)
  5. setUIFont(FontUIResource f)
  6. setUIFont(javax.swing.plaf.FontUIResource f)
  7. setUIFont(javax.swing.plaf.FontUIResource f)
  8. setUIFont(javax.swing.plaf.FontUIResource f)
  9. setUIFont(javax.swing.plaf.FontUIResource font)