Skip to content

Instantly share code, notes, and snippets.

@matthewmccullough
Created April 1, 2009 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matthewmccullough/88550 to your computer and use it in GitHub Desktop.
Save matthewmccullough/88550 to your computer and use it in GitHub Desktop.
Modify the Swing Defaults Table to a new Font
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