0

I'm a bit confused with what is happening with my GUI. In my program, I wanted to overwrite Nimbus' default font with my own custom font, so of course, I have this code in my program:

try {
        NimbusLookAndFeel laf = new NimbusLookAndFeel();
        UIManager.setLookAndFeel(laf);
        laf.getDefaults().put("defaultFont", courier);
} catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}

That's all fine and dandy except it doesn't overwrite all of the font. Just the font on the title borders. Example: Screenshot of program with UIManager code in program

Now, if I set the Look and Feel via VM Options in Netbeans, I get this result: Screenshot of programm with UIManager code in program AND VM Options set

If it's of any help, these are the VM Options I am using:

-Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel

My main concern with this is that when compiling into a 'fat jar' and running on another computer, the VM options don't seem to stick and I am left with the crappy looking first screen shot. So can anyone tell me why this is happening? Maybe offer up some kind of workaround or fix. Thanks!

EDIT: The nice looking theme (screenshot 2) doesn't seem to work outside of netbeans at all

zfollette
  • 475
  • 4
  • 15
  • Possible [duplicate](http://stackoverflow.com/q/30841389/230513): "Swing GUI objects should be constructed and manipulated only on the event dispatch thread, _after_ you've invoked `UIManager.setLookAndFeel()`." – trashgod Jul 25 '15 at 10:52
  • Thanks for the comment. Will try, though I question the possible duplicate. – zfollette Jul 25 '15 at 10:53
  • Did the suggested approach fix the problem? – trashgod Jul 26 '15 at 14:47
  • No. For some reason, the only thing that worked was setting the L&F to nimbus via -D flag, then setting it to nimbus again programmatically – zfollette Jul 26 '15 at 18:43
  • That is emblematic of the same underlying problem. – trashgod Jul 26 '15 at 18:47

0 Answers0