// Hello, world! applet
// demonostrates multiple methods that applets may use to communicate with user

import java.applet.*;                        // more than one "package" may be imported
import java.awt.*;

public class MyHelloApplet                   // save this to "MyHelloApplet.java"
  extends Applet                             // essential to create an applet
{
  final static String STR = "Hello, world!"; // defines a constant for the class

  public void init()
  {
    add(new Label(STR));                     // Static text may be stored onto a form
  }

  public void paint(Graphics g)
  {
    g.drawString(STR,200,100);               // Write a string to the screen, on the fly.
    showStatus(STR);                         // write a string to browser status bar 
    System.out.println(STR);                 // write string to "java console"
  }
}

1