title: Applet content disappears on resize
body: <p>I have never done Applet development. Trying something very simple. Basically I am drawing a string on the window. However, whenever I re-size the window the content disappears. </p>
  
  <p>A similar suggested question on SO recommended overriding the update() method to call repaint(). I tried that but that still didn't do it. Also how can I center the string ("Hello World!") on the window (so that it stays centered even on resize)?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  
  import javax.swing.JApplet;
  
  public class TestApplet extends JApplet
  {
   public void init(){
    setBackground (Color.gray);
   }
   public void paint (Graphics page){
    String name = "Hello World!";
    page.drawString(name,100,100);
   }
  
   public void update(Graphics page){
    this.repaint();
   }
  }
  </code></pre>