applet is not initialized. Help will be appreciated
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);
}
}
}
Re: applet is not initialized. Help will be appreciated
Look in the browser's java console for error messages.
What does the HTML look like that you are using to load this applet?
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
Re: applet is not initialized. Help will be appreciated
I am using bluej its like netbeans and eclipse just for simple programs so it pretty much does all the work for me all i do is press run?
Re: applet is not initialized. Help will be appreciated
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
You need to find where the java program shows the error messages.
In a browser it is in the java console. I don't know where to look in your IDE.
Re: applet is not initialized. Help will be appreciated
ok neither do but thanks anyways
Re: applet is not initialized. Help will be appreciated
Unless you can find an error message, you will have a hard time fixing the problem.