title: Why does my icon handling code throw a NullPointerException?
body: <p>I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me.</p>
  
  <pre><code>init:
  
  deps-jar:
  compile-single:
  run-single:
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
          at javax.swing.ImageIcon.&lt;init&gt;(ImageIcon.java:138)
          at ClientGUI.IdAndPasswordFrame.initComponents(IdAndPasswordFrame.java:91)
          at ClientGUI.IdAndPasswordFrame.&lt;init&gt;(IdAndPasswordFrame.java:22)
          at ClientGUI.IdAndPasswordFrame$4.run(IdAndPasswordFrame.java:200)
          at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
          at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
          at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
          at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
          at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
          at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
          at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
          at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
  BUILD SUCCESSFUL (total time: 1 second)
  </code></pre>
  
  <p>line 138:</p>
  
  <pre><code>public ImageIcon (URL location) {
      this(location, location.toExternalForm());
  }
  </code></pre>
  
  <p>line91:</p>
  
  <pre><code> jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/yahoo_1.gif"))); // NOI18N
  </code></pre>
  
  <p><strong>I use this poor checking (Peter Lang recommended)which is:System.out.println(getClass().getResource("/Images/yahoo_1.gif")); and it returns null,why? please help me.</strong></p>