Sunday, November 30, 2008

Polygon

import java.awt.*;

class PolyFigures extends Frame

{

int x1[] = {50, 25, 40, 100, 80};

int x2[] = {80, 30, 50, 150, 100, 170};

int y1[] = {50, 70, 120, 120, 80};

int y2[] = {150, 170, 200, 220, 240,190};


public PolyFigures()

{

super ("Poly figures");

setSize(300, 300);

setVisible (true);

}

public void paint (Graphics g)

{

g.drawPolygon (x1, y1, 5);

g.setColor (Color.cyan);

g.fillPolygon (x2, y2, 6);

}

public static void main (String args[])

{

new PolyFigures();

}

}