title: Image drawing with PaintComponent Java
body: <p>I'm studying java currently, and yet again I ran into a code in the book which doesn't wanna work and i can't figure out why. This code snippet is from Head First Java</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class SimpleGui {
  
      public static void main (String[] args){
          JFrame frame = new JFrame();
          DrawPanel button = new DrawPanel();
  
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          frame.getContentPane().add(button);
  
          frame.setSize(300,300);
  
          frame.setVisible(true);
      }
  }
  
  
  import java.awt.*;
  import java.lang.*;
  
  public class DrawPanel extends JPanel {
  private Image image;
  
  public DrawPanel(){
      image = new ImageIcon("cat2.jpg").getImage();
  }
  public void paintComponent(Graphics g){
  
      g.drawImage(image,3,4,this);
      }
  }
  </code></pre>
  
  <p>the image is in the same directory where my class files are, and the image is not showing. What am i missing here?</p>