颜色填充

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)