Applet calling paint method twice = for loop running twice?
Hi guys, semi-long time troller but new member.
I am trying to learn java and in an exercise to write a simple applet w/ a for loop inside, I am getting some interesting results. I wrote a test class to help me debug but I feel the cause of the problem is beyond my java understanding.
With a simple applet class and paint method, like the one below, the oval is drawn except the output in the console is double what my for loop should be. See below for code + return
Code:
import java.applet.*;
import java.awt.*;
public class test extends Applet{
public void paint (Graphics p){
p.fillOval(10, 10, 5, 5);
for (int i=1; i<=4; i++){
System.out.println(i);
}
}
}
and the return is
Am I using poor form when writing this simple program? Perhaps the for loop should be outside of the paint method? The real purpose of the for loop is to draw different ovals on the applet, which is why it would be convenient to have it inside. I don't think it matters but I don't have any other ideas as to the problem.
Thanks in advance