      1  import java.awt.Graphics;

      2  import java.awt.Graphics2D;

      3  import javax.swing.JComponent;

      4

      5  /**

      6     This component draws two car shapes.

      7  */

      8  public class CarComponent extends JComponent

      9  {

     10     public void paintComponent(Graphics g)

     11     {

     12        Graphics2D g2 = (Graphics2D) g;

     13

     14        Car car1 = new Car(0, 0);

     15

     16        int x = getWidth() - 60;

     17        int y = getHeight() - 30;

     18

     19        Car car2 = new Car(x, y);

     20

     21        car1.draw(g2);

     22        car2.draw(g2);

     23     }

     24  }