三角形を埋めようとしています。私はそれを自分でやろうとしました
g.fillPolygon(Triangle.x1, Triangle.x2, Triangle.x3, Triangle.y1,
Triangle.y2, Triangle.y3);
しかし、私はいくつかのエラーが発生しています。誰でもこれで私を助けることができますか?
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Vehicle extends JFrame
{
final int WIDTH = 900; int HEIGHT = 650;
public Vehicle()
{
//the following code creates the JFrame
super("Radical Racing");
setSize(WIDTH,HEIGHT);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public void paint(Graphics g)
{
g.setColor(Color.DARK_GRAY);
g.fillRect(0,0,WIDTH,HEIGHT);
int x1, y1 ,x2, y2, x3,y3;
x1 = x2 = x3 = 200;
y1 = y2 = y3 = 390;
{
triangle (g, x1=174, y1, x2=204, y2, x3=189, y3=360);
}
g.setColor(Color.green);
g.fillPolygon(Triangle.x1, Triangle.x2, Triangle.x3, Triangle.y1, Triangle.y2, Triangle.y3);
triangle(g,x1,y1,x2,y2,x3,y3);
}
void triangle(Graphics g,int x1,int y1,
int x2, int y2, int x3, int y3){
g.drawLine (x1, y1, x2, y2);
g.drawLine (x2, y2, x3, y3);
g.drawLine (x3, y3, x1, y1);
}
public static void main(String[]args)
{
new Vehicle();
}
}