2 Replies Latest reply: Oct 2, 2012 5:54 AM by gimbal2 RSS

    Swing and Nimbus Java Bug

      I have a simple app with 2 frames and Nimbus for L&F. I'm running against this bug:


      I can't vote on it (?) and it's low priority for some reason. However, when my second frame loads it's all messed up and the app crashes so it's a showstopper for me.

      I've no clue where to look for a workaround or what I can do to prevent this. If the first frame is never opened it doesn't happen, but if it is opened, the app crashes when adding a panel with components to the second frame and setting it visible.

      Please help me finding a workaround or solution for this problem. I can't just let Nimbus out.
        • 1. Re: Swing and Nimbus Java Bug
          The problem was caused by missing "defaultFont" key in UIDefaults. This key is needed by many UI delegates in Nimbus look and feel. Inspired by this commit:


          I decided to change the font defaults via the ui manager. There I had a new problem and following the (non-accepted) solution as proposed by Arnon on this thread:


          And using inspection to get around the problem that Nimbus changed packages in JDK releases,

          I got to this workaround:

          try {
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                    UIManager.getDefaults().put("defaultFont", new Font(Font.SANS_SERIF, 0, 12));
                    log.info("setting nimbus look and feel");
                    } catch (Exception e) {

          Now I can start developing.
          • 2. Re: Swing and Nimbus Java Bug
            Thanks for posting back, I'm sure you save someone the trouble of doing the same research you did. Please use \
             tags in the future to make code more clear and to stop the forum from trying to interpret it.