title: setting background image in Java
body: <p>OK, first thing I want to say is: yes, I know there are a number of similar questions on setting a background image in java. However, my situation is a bit different since I got handed a Java project that was started by someone else. I believe that the previous programmer was fairly new to Java GUI programming and I myself am <strong>very</strong> new to Java GUI programming. Here is what the program will have to do:</p>
  
  <ul>
  <li>Set up a background image which is a network map of our clients</li>
  <li>Place bandwidth maps to respective clients which is acquired by a url</li>
  <li>Refresh bandwidth graphs every 5 seconds or so</li>
  </ul>
  
  <p>The only thing that the previous programmer did was set up 2 classes, one being the main and one setting up the background image which he had as a monkey from a url</p>
  
  <p>Now, I decided to use MigLayout to organize a grid where I will place the bandwidth images in the correct arrangement. I was having trouble with that so I decided to start a little smaller and change the monkey background to the network map. I added the map jpg to the src library and thought that if I switched URL to File it would work. It didn't and I have been stuck trying to switch things around to get it to work but no cigar.</p>
  
  <p>Below is the code for the setting up a background. This is my first time trying to post code I hope it works:... well I tried several times several ways and googled it several time but posting my code isnt working so I took a screen shot. Nothing is working for me today. <img src="https://i.stack.imgur.com/jYjaz.png" alt="enter image description here"></p>
  
  <p>The errors I get are:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at javax.swing.ImageIcon.&lt;init&gt;(Unknown Source)
      at bwMonBackground.&lt;init&gt;(bwMonBackground.java:21)
      at bwMonBackgroundMain.main(bwMonBackgroundMain.java:7)
  </code></pre>
  
  <p>EDIT: I uncommented out line 18. Here is the main:</p>
  
  <pre><code>public class bwMonBackgroundMain extends bwMonBackground{
        public static void main( String[] args )
          {
              bwMonBackground frame = new bwMonBackground();
              migLayout testing = new migLayout();
              testing.createLayout();
              frame.setVisible(true);
              frame.setResizable(false);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
  
          }
  }
  </code></pre>
  
  <p>EDIT 2: once i uncommented out line 18 in bwMonBackground.java I get the following errors:</p>
  
  <pre><code>javax.imageio.IIOException: Can't read input file!
      at javax.imageio.ImageIO.read(Unknown Source)
      at bwMonBackground.&lt;init&gt;(bwMonBackground.java:15)
      at bwMonBackgroundMain.main(bwMonBackgroundMain.java:7)
  Exception in thread "main" java.lang.NullPointerException
      at javax.swing.ImageIcon.&lt;init&gt;(Unknown Source)
      at bwMonBackground.&lt;init&gt;(bwMonBackground.java:20)
      at bwMonBackgroundMain.main(bwMonBackgroundMain.java:7)
  </code></pre>