Note that there are some explanatory texts on larger screens.

plurals
  1. POJava: Altering UI fonts (Nimbus) doesn't work!
    text
    copied!<p>I'm referring to <a href="http://jasperpotts.com/blogfiles/nimbusdefaults/nimbus.html" rel="noreferrer">this Nimbus reference</a>. </p> <p>I tried to set global Font to be slightly larger:</p> <pre><code>UIManager.put("defaultFont", new Font(Font.SANS_SERIF, 0, 16)); </code></pre> <p>...works only for the menu but <strong>nothing</strong> else (buttons, labels).</p> <p>I tried to change labels and buttons fonts with</p> <pre><code>UIManager.put("Button.font", new Font(Font.SANS_SERIF, 0, 16)); UIManager.put("Label.font", new Font(Font.SANS_SERIF, 0, 16)); </code></pre> <p>but the font <strong>remains</strong>.</p> <p>The only thing that worked for me was <strong>deriving</strong> a font:</p> <pre><code>someButton.setFont(someButton.getFont().deriveFont(16f)); </code></pre> <p>But this is not an option, since this must be done for <strong>each</strong> element manually.</p> <p>Note, that deriving a font for UIManager <strong>doesn't work</strong> either:</p> <pre><code>UIManager.put("Label.font", UIManager.getFont("Label.font").deriveFont(16f)); </code></pre> <p>I tested everything under Linux and Windows: same behavior.</p> <p><em>I just can't understand how an API can be so messy. If a method is called setFont(..) then <strong>I expect it</strong> to set the font. If this method fails to set the font in any thinkable circumstances, then it should be deprecated.</em></p> <p><strong>EDIT:</strong><br> The problem not only applies to Nimbus, but also to the default LAF.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload