title: I don't understand the error
body: <p>I am trying to get a background image for my applet assignment for school and i am getting an error i don't understand. Also using Ready-to-Program if that is relevant </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import java.applet.*;
  import java.net.*;
  
  public class Summative extends Applet
      implements ActionListener
  {
      Button bttn1 = new Button ("Formulas");
      Button bttn2 = new Button ("Start");
      boolean Formulas = false;
      boolean Start = false;
      URL url;
      Image background;
      public void init ()
      {
          setSize (1000, 1000);
          try
          {
              url = getDocumentBase ();
          }
          catch (Exception e)
          {
          }
          background = getImage(url, "MathMeme.JPEG");
  
          setBackground (Color.white);
          bttn1.addActionListener (this);
          bttn2.addActionListener (this);
          add (bttn1);
          add (bttn2);
      }
  
  
      public void paint (Graphics g)
      {
          g.setColor (Color.white);
          g.drawImage (background, 0, 0, this);
          /*if (Formulas == true)
          {
              Dimension d = getSize();
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, d.width, d.height);
              g.drawString ("Enter Formulas here", 100, 100);
          }*/
      }
  
  
      public void actionPerformed (ActionEvent evt)
      {
          if (evt.getSource () == bttn1)
          {
              Formulas = true;
              repaint ();
          }
      }
  }
  </code></pre>
  
  <p>and this is the error i am getting:</p>
  
  <pre><code>java.lang.NullPointerException
      at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
      at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
      at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
      at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
      at Summative.paint(Summative.java:38)
      at sun.awt.RepaintArea.paint(Unknown Source)
      at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>i thought null pointer exception was when you have a try and access something with a null value so i dont understand how i can have one in this program. </p>