title: Cannot see figures on screen when painting with JPanel
body: <p>Please, if someone can explain why I see only one line on panel running this code.
  When I remove all frame.add() lines below and keep only one, I can actually choose which line to see but how can I see them all?</p>
  
  <p>Here is main method creating JFrame</p>
  
  <pre><code>public class Main extends JPanel {
   public static void main(String[] args) {
      JFrame frame = new JFrame("Drawing Board");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(400, 400);
      frame.setVisible(true);
      MyLine line1 = new MyLine(70, 100, 120, 150, Color.BLACK);
      MyLine line2 = new MyLine(60, 80, 120, 150, Color.blue);
      MyLine line3 = new MyLine(50, 65, 120, 150, Color.BLACK);
      MyLine line4 = new MyLine(40, 25, 120, 150, Color.blue);
      MyLine line5 = new MyLine(30, 90, 120, 150, Color.BLACK);
      MyLine line6 = new MyLine(20, 130, 120, 150, Color.blue);
      JPanel panel = new JPanel();
  
      panel.add(line1);
      panel.add(line2);
      panel.add(line3);
      panel.add(line4);
      panel.add(line5);
      panel.add(line6);
      frame.add(panel);
    }
  }
  </code></pre>
  
  <p>My line method extends MyShape</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class MyLine extends MyShape {
  
   public MyLine(int x1,int y1,int x2,int y2,Color colorOfLine){
      super(x1, y1, x2, y2, colorOfLine);
  }
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(shapeColor);
      g.drawLine(x1, y1, x2, y2);
   }
  }       
  </code></pre>
  
  <p>MyShape extends jpanel</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public abstract class MyShape extends JPanel {
  protected int x1,x2,y1,y2;
  protected Color shapeColor;
  protected MyShape(int x1,int y1,int x2,int y2,Color colorOfShape) {
      this.x1=x1;
      this.x2=x2;
      this.y1=y1;
      this.y2=y2;
      shapeColor = colorOfShape;
  }
  </code></pre>