Search code examples
javaappletscreen

Java Applet Clear Screen


For Java Applets, what is the best method of "clearing the screen"? Is there a particular function or would you create and paint a white rectangle the size of the screen?

What are the best practices for the purpose of clearing the entire applet screen?


Solution

  • Usually the best practices of clearing applet will be painting background

    Dimension d = getSize();
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, d.width, d.height);