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.
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)?
Here is the 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();
}
}