class background {
public static void moon(Graphics g) {
int k2 = 0;
int k3 = 0;
for (int k = 0; k <= 550; k+=2) {
if (k2 == 550) {
for (k2 = 550; k3 <= 550; k3+=2) {
k = 0;
g.setColor(Color.blue);
g.fillOval(k3,50,50,50);
for(long delay = 1; delay<1000000; delay++);
g.setColor(Color.white);
g.fillOval(k3,50,50,50);
k2 = 0;
}
} else {
k2+=2;
k3=0;
g.setColor(Color.black);
g.fillOval(k,50,50,50);
for(long delay = 1; delay<1000000; delay++);
g.setColor(Color.white);
g.fillOval(k,50,50,50);
}
}
}
}
This is my problem: in the applet it will show the black ball go across, then the blue ball, then the black ball. Then it won’t show anything else. What I want is it to just continue to loop black, blue, black, blue, and just keep going on and on.
It would appear you were just lacking a while loop to keep you going. Something like…
Would be what you’re looking for.