Search code examples
javaappletawtpaintthread-sleep

What is really happening when the applet window size is changed by the user?


Whenever I drag to change the window size in my applet, the paint method appears to run again. What is really happening? Is the paint method just re-running itself? Is there a way I can make it do this automatically (without changing the window size)? The for loop does not seem to be working. I had a thread.sleep method in the code but it still didn't help. I will include the code for the paint method below.

// -----------------------------------------------------------------
// Paints the stick figures on the applet.
// -----------------------------------------------------------------
public void paint(Graphics page) {
    // for (int f = 0; f < 6; f++) {

    resize(400, 150);
    for (int u = 0; u < stickdudes.length; u++)
        stickdudes[u].draw(page);

    // Delay.sleep(3000);
    // }
}

Solution

  • to call the paint() method again and again the repaint() method is used both in AWT and Swing