Forked from matthewmccullough/SetSwingDefaultFont.java
Created
April 14, 2010 15:21
-
-
Save stigkj/365909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void setSwingFontDefault(javax.swing.plaf.FontUIResource newFont) { | |
java.util.Enumeration<Object> uiManagerKeys = UIManager.getDefaults().keys(); | |
while (uiManagerKeys.hasMoreElements()) { | |
Object key = uiManagerKeys.nextElement(); | |
Object value = UIManager.get(key); | |
if (value instanceof javax.swing.plaf.FontUIResource) | |
UIManager.put(key, newFont); | |
} | |
} | |
//Example call | |
setSwingFontDefault(new FontUIResource("Serif", Font.PLAIN, 16)); | |
//Or to directly set a font for just ONE component, such as Labels | |
UIManager.put("Label.font",new Font("Serif",Font.ITALIC,12)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment