title: Can't get JFrame to refresh image
body: <p>Hey, so I'm working on a program and for debugging purposes, I'm trying to get the program to take a screenshot of a part of the display. I want to have the display updated, but I can't seem to get it to work. I'm sure it's a simple issue, but my experience with Java Applets is very small.</p>
  
  <p>Here's the part that I'm having issues with:</p>
  
  <pre><code>...
  Thread.sleep(5000);
      try {gb = new GameBoard(frame.getBounds());}
      catch(Exception e){System.out.println("Error.");} // Make "gameboard" Object
  
      while (true)
      {
          Thread.sleep(1000);
          gb.grabImage(); // use java.awt.Robot's createScreenCapture()
  
          ImageIcon icon = new ImageIcon(gb.image()); // wrap the image 
          JLabel label = new JLabel(icon, JLabel.CENTER);
          frame.getContentPane().add(label,BorderLayout.EAST); //display the image (works)
          //JOptionPane.showMessageDialog(null, label, "icon", -1);
          label.repaint(); //update the display??
          frame.repaint();
          frame.getContentPane().repaint();
      }
  </code></pre>
  
  <p>As I said, the image appears, and will create new ones if I change the Applet size, but I need a constantly changing image.</p>
  
  <p>Thanks in advance!</p>