title: How to render a 2d image in Java
body: <p>I have a quick question about Java. I'm sorry if this question is really basic, but I'm a beginner Java programmer :D </p>
  
  <p>I want to render a 2d image in a window, but I can't figure it out. I've looked at the graphics API here: </p>
  
  <p><a href="http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html" rel="nofollow">http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html</a></p>
  
  <p>and the only method I could find that might work is drawImage().
  It wasn't working for me, though, but maybe it has to do with the ImageObserver Observer parameter? I just put null for that following some tutorial I found somewhere, but I still get a compile error:
  Here is my paint method:</p>
  
  <pre><code>public void paint(Graphics g)
  {   
      Image img1 = Toolkit.getDefaultToolkit().getImage("theImage.png");
      g.drawImage(img1, 100, 100, null);
  } // public void paint(Graphics g)
  </code></pre>
  
  <p>and here are the methods that call it:</p>
  
  <pre><code>public static void main(String[] args)
  {
      MyGame game = new MyGame();
      game.setVisible(true);
      game.play();      
  
  } // public static void main(String[] args)
  
  
  
  /** The play method is where the main game loop resides. 
   */
  public void play()
  {
      boolean playing = true;
      //Graphics g = new Graphics();
      while (playing)
      {
          paint();
      }
  
  } //  public void play()
  </code></pre>
  
  <p>The thing is when I call paint in the while loop, I get this error:
      paints(java.awt.Graphics) in MyGame cannot be applied to ()</p>
  
  <p>What does that mean? How can I fix it so I can successfully render a 2d image?</p>
  
  <p>Thanks in advance :D</p>