Draw Polygons in java applet

Hello Friends, 

Today I will explain how can we draw Polygon in java applet.
In this  program I have print simple Polygon but you can draw different shapes with different size.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

/*


*/

public class polydemo extends Applet
{
public void paint(Graphics g)
{
int xpt[]={60,30,30,30,120};
int ypt[]={90,40,180,180,30};

int num=5;
g.drawPolygon(xpt,ypt,num);
g.setColor(Color.green);
g.fillPolygon(xpt,ypt,num);
g.setColor(Color.blue);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *