filmov
tv
Java Programming , this program draws 4 cars and one sword on the component file
Показать описание
Create another two picture class. Include these two pictures on the CarComponent, so you have 1 other picture. beside the 4 cars.
/**
This component draws two car shapes.
*/
public class CarComponent extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Car car1 = new Car(0, 0);
int x = getWidth() - 60;
int y = getHeight() - 30;
Car car2 = new Car(x, y);
Car car3 = new Car(50,100);
Car car4 = new Car(50,250);
Sword sword1 = new Sword(150, 300);
}
}
/**
This component draws two car shapes.
*/
public class CarComponent extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Car car1 = new Car(0, 0);
int x = getWidth() - 60;
int y = getHeight() - 30;
Car car2 = new Car(x, y);
Car car3 = new Car(50,100);
Car car4 = new Car(50,250);
Sword sword1 = new Sword(150, 300);
}
}