title: Why does Synth keeps throwing NullPointerExceptions when trying to apply a style?
body: <p>Whenever I try to apply a style to a JMenu or a JMenuItem (via Synth) I get a lot of NullPointerExceptions whenever I hover or click the JMenuItems or the JMenu itself, the stack trace isn't giving me any useful information and doesn't point anywhere at any of my source files.</p>
  
  <p>I am loading the file correctly and it <strong>does</strong> display the styles (apart from the background colors but that's aside) the problem is that I get a lot of Exceptions while everything is working just fine, the program doesn't crash.</p>
  
  <p>this is the synth LookAndFeel.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;synth&gt;
  
      &lt;style id="menuBarStyle"&gt;
          &lt;state&gt;
              &lt;color value="GRAY" type="BACKGROUND"/&gt;
          &lt;/state&gt;
      &lt;/style&gt;
      &lt;bind style="menuBarStyle" type="region" key="MenuBar"/&gt;
  
      &lt;style id="menuStyle"&gt;
          &lt;insets top="5" bottom="3" right="10" left="10"/&gt;
          &lt;state&gt;
              &lt;color value="RED" type="BACKGROUND"/&gt;
          &lt;/state&gt;
      &lt;/style&gt;
      &lt;bind style="menuStyle" type="region" key="Menu"/&gt;
  
      &lt;style id="menuItemStyle"&gt;
          &lt;insets top="5" bottom="5" left="10" right="3"/&gt;
          &lt;state&gt;
              &lt;color value="GREEN" type="BACKGROUND"/&gt;
          &lt;/state&gt;
      &lt;/style&gt;
      &lt;bind style="menuItemStyle" type="region" key="MenuItem"/&gt;
  
      &lt;style id="menuItemAcceleratorStyle"&gt;
          &lt;state&gt;
              &lt;color value="GRAY" type="BACKGROUND"/&gt;
          &lt;/state&gt;
      &lt;/style&gt;
      &lt;bind style="menuItemAcceleratorStyle" type="region" key="MenuItem"/&gt;
  
  &lt;/synth&gt;
  </code></pre>
  
  <p>This is how I load the file:</p>
  
  <pre><code> private void initUI() {
          try {
              SynthLookAndFeel laf = new SynthLookAndFeel();
              laf.load(getClass().getClassLoader().getResourceAsStream("LookAndFeel.xml"), getClass());
              UIManager.setLookAndFeel(laf);
          } catch (ParseException e) {
              e.printStackTrace();
          } catch (UnsupportedLookAndFeelException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>And this is the stack trace (printed repeatedly whenever there is an interaction with the styled components):</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
      at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
      at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
      at javax.swing.JComponent.getFontMetrics(JComponent.java:1626)
      at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:125)
      at javax.swing.plaf.synth.SynthMenuItemLayoutHelper.&lt;init&gt;(SynthMenuItemLayoutHelper.java:119)
      at javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:501)
      at javax.swing.plaf.synth.SynthMenuItemUI.paint(SynthMenuItemUI.java:281)
      at javax.swing.plaf.synth.SynthMenuItemUI.update(SynthMenuItemUI.java:245)
      at javax.swing.JComponent.paintComponent(JComponent.java:780)
      at javax.swing.JComponent.paint(JComponent.java:1056)
      at javax.swing.JComponent.paintChildren(JComponent.java:889)
      at javax.swing.JComponent.paint(JComponent.java:1065)
      at javax.swing.JComponent.paintChildren(JComponent.java:889)
      at javax.swing.JComponent.paint(JComponent.java:1065)
      at javax.swing.JComponent.paintChildren(JComponent.java:889)
      at javax.swing.JComponent.paint(JComponent.java:1065)
      at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
      at javax.swing.JComponent.paintChildren(JComponent.java:889)
      at javax.swing.JComponent.paint(JComponent.java:1065)
      at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
      at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
      at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
      at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
      at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
      at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
      at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
      at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
      at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
      at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
      at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  </code></pre>
  
  <p>I suspect that the problem has something to do with Synth itself rather than my code I suppose, I tried looking up on the internet and in the java documentation and tutorials on Synth but couldn't find anything relevant.</p>
  
  <p><strong>P.S:</strong> I call this method <strong>before</strong> I start displaying or creating any swing components.</p>