title: JAVA, GUI JPanel, JFrame, paintComponent, Graphics
body: <p>Regarding your comment to change add public display(Graphics g)</p>
  
  <p>[link]<a href="http://www3.canyons.edu/Faculty/biblej/project6.html" rel="nofollow">http://www3.canyons.edu/Faculty/biblej/project6.html</a></p>
  
  <p>1.)Project6 class will have to extend the JFrame class
  2.)Project6 constructor will have to set up the GUI window.
  3.)A new abstract method:  public void display(Graphics g);  should be added to the base and derived classes
  4.)A custom JPanel must be set up with a paintComponent method
  5.)The new display(Graphics g) method will have to draw the shapes on the GUI window and be called from a loop in the paintComponent method</p>
  
  <pre><code>public class Project6 extends JFrame { 
  
  //project6 constructor without parameters to set up new JFrame
  public Project6() {
  add(new NewPanel());
  }
  class NewPanel extends JPanel {
  @Override
  protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  </code></pre>
  
  <p>//So do I need to add Graphics g here? or no?</p>
  
  <pre><code>for(int i = 0; i &lt; thearray.length &amp;&amp; thearray[i] != null; i++) {
  thearray[i].display(**Graphics g**); 
  }}}
  
  public static void main (String [] args) {
  JFrame frame = new JFrame();
  frame.setSize(800, 700);                           
  frame.setTitle("Shapes");
  frame.setLocationRelativeTo(null);                 //Center Frame
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
  </code></pre>
  
  <p>Here is one of classes for example, Do I add it to the end like this? and do I need to add a public abstract void display(Graphics g) to the Shape parent class? and how would it call in the project6 class?</p>
  
  <pre><code>public class Rectangle extends Shape {
  private int width;
  private int height;
  
  public Rectangle() {
      setWidth(0);
      setHeight(0);
      setXPos(0);
      setYPos(0);}
  
  public Rectangle(int xPos, int yPos, int height, int width) {
      setWidth(xPos);
      setHeight(yPos);
      setXPos(height);
      setYPos(width);}
  
  public int getWidth() {
      return width;}
  
  public void setWidth(int width) {
      this.width = width;}
  
  public int getHeight() {
      return height;}
  
  public void setHeight(int height) {
      this.height = height;}
  
  @Override
  public void display() {
      System.out.println("Rectangle: (" + getXPos() + ", " + getYPos() + ") " + " Height:  " + height + " Width: " + width);}
  
  @Override
  public void display(Graphics g) {
    g.drawRect(getXPos(), getYPos(), width, height); }
  </code></pre>