title: Drawing Multiple JComponents to a Frame
body: <p>I am trying to draw multiple car objects onto the same window but it appears that they are overwriting each other.</p>
  
  <p>Here is my overridden paintComponent method in the Car class</p>
  
  <pre><code>public void paintComponent(Graphics g) {
      Graphics2D g2 = (Graphics2D) g;
  
      g2.setColor(wheelColor);
      g2.fill(leftWheel);
      g2.fill(rightWheel);
      g2.setColor(bodyColor);
      g2.fill(body);
      g2.fill(cab);
  }
  </code></pre>
  
  <p>And in my Viewer Class:</p>
  
  <pre><code>JFrame f = new JFrame();
  initializeFrame(f);
  
  Car x = new Car(100, 100);
  Car y = new Car(300, 300);
  
  f.add(x);
  f.add(y);
  </code></pre>
  
  <p>Although the coordinates seem to be different, only the last car is being drawn.</p>
  
  <p>Any suggestions? Thanks</p>