title: drawing simple rectangles on a Jframe in java
body: <p>I am extending JFrame like this:</p>
  
  <pre><code>public GameFrame() {
      this.setBounds(30, 30, 500, 500);
      this.setDefaultCloseOperation(EXIT_ON_CLOSE);
      initializeSquares();
  }
  
  private void initializeSquares(){
      for(int i = 0; i &lt; 5; i++){
          this.getContentPane().add(new Square(i*10, i*10, 100, 100));
      }
      this.setVisible(true);
  }
  </code></pre>
  
  <p>However, only one square is being drawn on the screen, does anybody know why?</p>
  
  <p>also My Square class looks like this:</p>
  
  <pre><code>private int x;
  private int y;
  private int width;
  private int height;
  public Square(int x, int y, int width, int height){
      this.x = x;
      this.y = y;
      this.width = width;
      this.height = height;
  }
  
  @Override
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.drawRect(x, y, width, height);
  }
  </code></pre>