Revisions

gist: 88550 Download_button fork
public
Description:
Modify the Swing Defaults Table to a new Font
Public Clone URL: git://gist.github.com/88550.git
Embed All Files: show embed
SetSwingDefaultFont.java #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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));