title: Update LookAndFeel Values On The Fly
body: <p>I want to be able to update the LookAndFeel attributes of my Swing GUI on the fly. In this case, I have a simple Swing/Awt game running what starts out as the Nimbus <code>LookAndFeel</code>. At various points after start up I want to change (let us say) just one detail: the background color of my application.</p>
  
  <p>I can change the background color by doing this:</p>
  
  <pre><code>for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
      if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          UIManager.getLookAndFeelDefaults().put("Panel.background", Color.RED);
          SwingUtilities.updateComponentTreeUI(SomeGame.this);
          break;
      }
  }
  </code></pre>
  
  <p>This "works" in that the background color of the app changes correctly and the program doesn't crash. But on the command line I get error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at javax.swing.plaf.synth.SynthLookAndFeel.paintRegion(SynthLookAndFeel.java:371)
      at javax.swing.plaf.synth.SynthLookAndFeel.update(SynthLookAndFeel.java:335)
  </code></pre>
  
  <p>Obviously, something is null, but I can not figure out what it is or how to fix it. There must be something I don't understand. I have looked at other StackOverflow questions about <a href="https://stackoverflow.com/questions/14700758/how-to-change-background-color-for-nimbus-look-and-feel-using-java">setting background colors in Nimbus</a> and <a href="https://stackoverflow.com/questions/12492114/overriding-lookandfeel">overriding the LookAndFeel information after startup</a>.</p>
  
  <ul>
  <li>When I call <code>getLookAndFeelDefaults()</code> do I need to specify the rest of the defaults as well?</li>
  <li>Have there been changes in how this works between Java 1.6 and 1.7?</li>
  </ul>