Paint Method Help
Hello Everyone,
I am working for the first time with applets. And I'm trying to understand the
paint method. I am trying to create an applet that draws 100 lines, randomly placed throughout the applet boundaries, pausing between each one. When I call repaint(); at the end, is that erasing the line that i just drew to redraw another one? How do I make them all stay on the screen? Below is my code.. don't make fun haha
import java.awt.*;
import java.util.*;
import java.lang.*;
publicclass assn3extends java.applet.Applet{
int randx, randy, randx2, randy2, count = 0;
Random generator =new Random();
/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
publicvoid init(){
}
publicvoid paint(Graphics g){
g.setColor(Color.red);
if (count < 100){
randx = generator.nextInt(700);
randy = generator.nextInt(700);
randx2 = generator.nextInt(700);
randy2 = generator.nextInt(700);
try{
Thread.sleep(7000);
}catch ( InterruptedException e ){
// do nothing
}
g.drawLine(randx, randy, randx2, randy2);
count++;
}
else{
g.setColor(Color.white);
g.fillRect(0, 0, bounds().width, bounds().height);
count = 0;
}
repaint();
}
}

