title: Java .drawImage : How do I "unDraw" or delete a image?
body: <p>I need a certain image to be redrawn at different locations constantly as the program runs. So  I set up a while loop that should move an image across the screen, but it just redraws the image on top of itself over and over again. What am I doing wrong? Is there a way to delete the old image before drawing it in a new location?</p>
  
  <pre><code>        JFrame frame = buildFrame();
  
      final BufferedImage image = ImageIO.read(new File("BeachRoad_double_size.png"));
  
      JPanel pane = new JPanel() {
          @Override
          protected void paintComponent(Graphics g) {
              super.paintComponent(g);
              int num = 0;
              boolean fluff = true;
              while (fluff == true) {
              num = num + 1;
              g.drawImage(image, num, 0, null);
              if (num == 105) {
                  fluff = false;
              }
              }
          }
      };
  
  
      frame.add(pane);
  </code></pre>