颜色填充
程序员文章站
2022-03-21 10:31:35
...
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
public class DrawLine extends Applet {
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D)g;
GeneralPath path = new GeneralPath();
path.moveTo(50,15);
path.lineTo(100,50);
path.lineTo(100,150);
path.lineTo(50,200);
path.lineTo(50,15);
g2D.setColor(Color.RED);
g2D.fill(path);
}
}