Setting the global font for a Java application

I need to set the default font for my application. Is there a way to do this that is independent of LaF?

+7
source share
2 answers

It revealed:

A call using setUIFont (new javax.swing.plaf.FontUIResource(new Font("MS Mincho",Font.PLAIN, 12)));

 private static void setUIFont(javax.swing.plaf.FontUIResource f) { java.util.Enumeration<Object> 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); } } } 
+5
source

for better control on how / which fonts to replace - in an LAF-independent way, but controlled per-laf - see the JGoodies Looks project

http://java.net/projects/looks

It allows you to exchange all FontSets (that is, a set of semantic fonts, such as control, dialogue, message) at runtime.

+3
source

All Articles