title: What is the simplest way to draw in Java?
body: <p>What is the simplest way to draw in Java?</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class Canvas
  {
      private JFrame frame;    
      private Graphics2D graphic;
      private JPanel canvas;
  
      public Canvas()
      {
          frame = new JFrame("A title");
          canvas = new JPanel();
          frame.setContentPane(canvas);
          frame.pack();
          frame.setVisible(true);
      }
  
      public void paint(Graphics g){
          BufferedImage offImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
          Grapics2D g2 = offImg.createGraphics();
          g2.setColor(new Color(255,0,0));
          g2.fillRect(10,10,200,50);
      }
  }
  </code></pre>
  
  <p>This doesn't work and I have no idea how to get anything to appear.</p>