Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Java GUI help

  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Java GUI help

    I have numerous classes, one which extends JFrame, another extends JComponent, a viewer class, a class for generating random numbers, a shape class and my main class.

    -the class with JComponent has an overridden paintComponent method, which paints shapes from shape class depending on the random number generated from the other class, so if ran number = 1, it will print out 1 dot.

    Each time I click a button in my main class, I want it to generate a new random number and draw a new image depending on the random number. all the action listener for the button does is update the label and call repaint.

    Each time I click the button, the Jlabel prints out the random number of the image before the one that's currently on screen.

    Program starts > empty label but image drawn with 2 dots > *click* label = 2 - diff image printed.

    Is there any way i can put them in sync with each other?

    I'm really sorry if this is too vague, but I don't want to paste code to avoid plagiarism by others.

    If this question structure was dumb and too vague, I may come back and rephrase or delete, thanks.

  2. #2
    New Coder
    Join Date
    Sep 2009
    Thanked 0 Times in 0 Posts
    Variable for the number of dots is not getting assigned by value of the random number generated in your program.
    int Num_of_dots = Ran_num; this is not getting implemented properly.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts