Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the font globally

Status
Not open for further replies.

GDameron

Programmer
Aug 8, 2003
39
US
The out-of-the-box font I'm seeing in my JFrame GUI is too small. Is there a way to globally set the font so that all JComponents inherit the larger font?

GD
 
I realise that there are probably better ways, but I use this:-
Code:
javax.swing.plaf.FontUIResource f = new FontUIResource("<fontname_here>", java.awt.Font.TRUETYPE_FONT, <fontsize_here>);

java.util.Enumeration keys = UIManager.getDefaults().keys();
      while (keys.hasMoreElements()) {
  Object key = keys.nextElement();
  Object value = UIManager.get (key);
  if (value instanceof javax.swing.plaf.FontUIResource)
    UIManager.put (key, f);
}

I've not had chance for ages to go back and re-consider this so I apologise if it's clunky.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top