欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

颜色填充

程序员文章站 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); 
	}
}
 
相关标签: Java