import java.applet.Applet;
import java.awt.*;
import java.awt.geom.*;
public class fillPoly extends Applet
{
    public void paint (Graphics g)
    {
	Graphics2D g2 = (Graphics2D) g;
	Color c1 = new Color (255, 255, 0);
	Color c2 = new Color (200, 0, 200);
	GradientPaint grad1 = new GradientPaint (10, 100, c1, 100, 100, c2);
	g2.setPaint (grad1);
	// draw GeneralPath (polygon)
	int x[] = {10, 100, 120, 100, 10};
	int y[] = {10, 10, 30, 50, 50};
	GeneralPath polygon = new GeneralPath (GeneralPath.WIND_EVEN_ODD, x.length);
	polygon.moveTo (x [0], y [0]);
	for (int index = 1 ; index < x.length ; index++)
	{
	    polygon.lineTo (x [index], y [index]);
	}
	polygon.closePath ();
	g2.fill (polygon);


	Color c3 = new Color (0, 0, 200);
	Color c4 = new Color (255, 255, 0);
	GradientPaint grad2 = new GradientPaint (10, 100, c3, 100, 100, c4);
	g2.setPaint (grad2);
	g2.fill (new Rectangle2D.Double (10, 100, 100, 100));
    }
}

