title: NullPointerException when trying to display image?
body: <p>This applet is a simple about the developer page in a website i'm  creating for a class project. I'm trying to display an image and a bio for each different JButton.
  I'm having an Issue with compiling, I keep getting a NullPointerException error
  on this line</p>
  
  <p><code>danPic = new ImageIcon(getClass().getResource("pics/danSkaggs.jpg"));</code></p>
  
  <p>Which i'm assuming it goes null because it can't find the image based on the directory i'm giving it. However I can't understand what I can do different, I can't see any problems with how the directory is written. The directory is pics/filename.jpg and the folder is in the same package as the Java code.</p>
  
  <p>Here is the full source code.</p>
  
  <pre><code>import java.util.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.*;
  
  public class Developers extends JApplet{
  private JButton danButton = new JButton("Dan Skaggs");
  private JButton brandonButton = new JButton("Brandon Shaw");
  private JButton jamesButton = new JButton("James Simpson");
  private JLabel bioLabel = new JLabel("Please click one of the buttons on the left.");
  JPanel centerPanel = new JPanel(new GridLayout(1, 2));
  JPanel mainPanel = new JPanel(new BorderLayout());
  JPanel westPanel = new JPanel(new GridLayout(1, 3));
  private ImageIcon danPic;
  private ImageIcon brandonPic;
  private ImageIcon jamesPic;
  private JLabel dLabel; 
  private JLabel bLabel; 
  private JLabel sLabel; 
  
  
  
  //This array carries the Bios of the group project members
  String[] bio = new String[]{"Insert Bio",
      "Insert Bio",
      "Insert Bio"};
  
  
  public Developers(){
      mainPanel.add(westPanel, BorderLayout.WEST);
      westPanel.add(danButton);
      westPanel.add(brandonButton);
      westPanel.add(jamesButton);
  
  
      centerPanel.add(bioLabel);
      mainPanel.add(centerPanel, BorderLayout.CENTER);
      danButton.addActionListener(new Handler());
      brandonButton.addActionListener(new Handler());
      jamesButton.addActionListener(new Handler());
  
      danPic = new ImageIcon(getClass().getResource("pics/danSkaggs.jpg"));
      brandonPic = new ImageIcon(getClass().getResource("pics/brandonShaw.jpg"));
      jamesPic = new ImageIcon(getClass().getResource("pics/jamesSimpson.jpg"));
  
      dLabel = new JLabel (danPic);
      bLabel = new JLabel (brandonPic);
      sLabel = new JLabel (jamesPic);
      centerPanel.add(dLabel);
      add(mainPanel);
  }
  
  
  private class Handler implements ActionListener{
      public void actionPerformed(ActionEvent event){
          if(event.getSource()== danButton){
              bioLabel.setText(bio[0]);
              centerPanel.add(dLabel);
          }
          else if(event.getSource()== brandonButton){
              bioLabel.setText(bio[1]);
              centerPanel.add(bLabel);
          }
          else if(event.getSource()== jamesButton){
              bioLabel.setText(bio[2]);       
              centerPanel.add(bLabel);
          }
      }
  }//end Handler class
  }//end Developer class
  </code></pre>