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.

Page 2 of 2 FirstFirst 12
Results 26 to 30 of 30

Thread: Random Shape Generator

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,164
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Random Shape Generator

    still get the same errors
    The code compiles for me. Make sure the Draw class has been compiled with the new source. Delete the Draw.class file to make sure.

    The default: case is still missing from the switch statement. You need it to print a message when its called.
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Junior Member
    Join Date
    Apr 2014
    Posts
    29
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default Re: Random Shape Generator

    So you're able to see the shapes generate? The code compiles for me as well but I only get an orange window.

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,164
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Random Shape Generator

    I only get an orange window.
    Is the paintComponent() method being executed?
    Did you add the default: case?
    If you don't understand my answer, don't ignore it, ask a question.

  4. The Following User Says Thank You to Norm For This Useful Post:

    sjdganc (August 31st, 2014)

  5. #29
    Junior Member
    Join Date
    Apr 2014
    Posts
    29
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default Re: Random Shape Generator

    I cannot see why the paintComponent is not being executed. The switch...case is inside this method. Not sure what the default case should be? I have the three different shapes that need to be drawn. Still get the orange window with a message added to the below code:

    public static int chooseShape();
         int theShape = 1 + gen.nextInt(3);
         System.out.printf("Shape value returned is %d\n", theShape);
         return theShape;


    --- Update ---

    Thank you Norm for your help all day. Been a long day. I will continue tomorrow after traveling most of the day to get home. Thanks again. I do appreciate it! Have a great holiday weekend.

  6. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,164
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Random Shape Generator

    I cannot see why the paintComponent is not being executed.
    How do you know if it is or not? Do you have a println statement in it that prints a message when it is called?

    What color is the Draw panel supposed to be? I see that the code sets the JPanel: panel to orange.
    Where does it set the Draw panel?
    If you don't understand my answer, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Random Number Generator
    By Rugby_Thompson in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 5th, 2013, 12:58 AM
  2. Random Number Generator Always gives 0
    By tlckl3m3elmo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 11th, 2012, 03:09 PM
  3. Random math problem generator?
    By CamCompetes in forum Member Introductions
    Replies: 1
    Last Post: March 9th, 2012, 02:42 PM
  4. random number generator
    By java3 in forum Loops & Control Statements
    Replies: 4
    Last Post: February 21st, 2011, 12:00 PM
  5. [SOLVED] Random number method implementation
    By big_c in forum Java Theory & Questions
    Replies: 2
    Last Post: April 15th, 2009, 01:10 PM