Here is my code for painting a number of random circles on a JApplet Graphics page.
I works, but seems to perform the 'public void paint (Graphics page)' method twice.
This happens for any value of 'numCircles'. I always get two sets of circles. It seems that one complete set (with a "largest red" circle) is painted, and then a second complete set is painted over the first - because sometimes there is a black circle outline painted over a red filled circle.
I can't get over thinking that the loop structure (line 20) is a potential cause of the problem even though the program outputs two complete sets of circles, including two "largest red" circles, and the "largest red" circle is painted outside of the loop. But to be safe, I have tried several variations of 'for' and 'while' loops, to no avail.
I've gotta be missing something simple. Pleeeeeease help....
Yes, by "them" I am referring to lines 17 and 18. The paint() methods is only called once when I remove them - but then I don't get the appearance I want. And when I manually resize the Applet window (Graphics page), it causes paint() to be called again.
posted 2 years ago
when I remove them
They should MOVED (not REMOVED) to the init() or start() method.