Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: applet is not initialized. Help will be appreciated

  1. #1
    Member
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default 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);
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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

  3. #3
    Member
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default 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?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.
    Last edited by Norm; March 14th, 2012 at 08:35 PM.

  5. #5
    Member
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: applet is not initialized. Help will be appreciated

    ok neither do but thanks anyways

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. variable might not have been initialized...help appreciated
    By neontiger in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 3rd, 2012, 05:58 PM
  2. Variable might not have been initialized
    By JavaGirl9001 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 7th, 2011, 11:24 AM
  3. Conditions and 'might not have been initialized' error.
    By mwebb in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 2nd, 2011, 11:22 AM
  4. variable might not have been initialized
    By SV25 in forum Java Theory & Questions
    Replies: 1
    Last Post: April 25th, 2011, 10:58 AM
  5. Variable might not have been initialized?
    By n56 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2010, 03:03 PM