title: Create Methods to Draw Rectangle and Circle in JFrame?
body: <p>I was assigned this problem without any teaching on how to do it and I can't figure it out on my own. I've started, but I can't figure out what methods to add.</p>
  
  <p>Below is the main method of a program which paints a circle and a square at the given coordinates. Your job is to write the rest of the code, BUT THE MAIN METHOD CANNOT BE ALTERED!!!  You can add methods to the main driver class but you CANNOT add anything to the main method below.</p>
  
  <pre><code>public static void main (String[] args){
  
  JFrame picture = new JFrame("Circle and Square"); 
  picture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  picture.getContentPane().add(new Drawing(200, 50,100, 150)); 
  picture.pack(); 
  picture.setVisible(true);
  
  }
  </code></pre>
  
  <p>The first two numbers are the height and width where the rectange should start and the second two numbers are the height and width where the circle should start.</p>
  
  <pre><code>//The following is my failure attempt, so at least you know I tried
  to figure something out.
  
  import javax.swing.*;
  import java.awt.*;
  
  public class Drawing extends JFrame
  {
  int a, b, c, d;
  public Drawing(int x, int y, int z, int yeah)
  {
      setSize(400, 400);
      a = x;
      b = y;
      c = z;
      d = yeah;
  }
  public void paint(Graphics g)
  {
      super.paint(g);
      g.drawRect(a, b, c, d);
      g.drawOval(c, d, a, b);
  }
  public getContentPane()
  {
  
  }
  //Can't change following class:
  public static void main (String[] args)
  {
      JFrame picture = new JFrame("Circle and Square");
      picture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      picture.getContentPane().add(new Drawing(200, 50, 100, 150));
      picture.pack();
      picture.setVisible(true);
  }
  }
  </code></pre>
  
  <p>I know I have to create something called a panel, but I don't even really understand how to do that. I'm sure I could reverse engineer any code anyone here shows me on how to solve my assignment. Thanks.</p>