Here is the code there are no syntax errors. but when i try to run the applet it tells me the applet is not initialized. can someone tell me what i am missing or doing wrong?
import java.awt.*;
import java.applet.*;
import java.awt.geom.*;
import java.util.*;
public class RandomPolygons extends Applet
{
private int[] xpoints={0,-10,-7,7,10};
private int[] ypoints={-10,-2,10,10-2};
private Polygon poly;
public void init()
{
poly = new Polygon(xpoints,ypoints,xpoints.length);
}
public void paint(Graphics g)
{
Graphics2D g2d=(Graphics2D)g;
AffineTransform identity = new AffineTransform();
Random rand= new Random();
int width = getSize().width;
int height= getSize().height;
g2d.setColor(Color.BLACK);
g2d.fillRect(0,0,width,height);
for(int n = 0; n < 300; n++)
{
g2d.setTransform(identity);
g2d.translate(rand.nextInt()% width,rand.nextInt()% height);
g2d.rotate(Math.toRadians(360*rand.nextDouble()));
g2d.scale(5*rand.nextDouble(),5*rand.nextDouble()) ;
g2d.setColor(new Color(rand.nextInt()));
g2d.fill(poly);
}
}
}