// Fig. 10.5: MyLabel.java
// Demonstrating the Label class.
import java.applet.Applet;
import java.awt.*;

public class MyLabel extends Applet {
   private Label label1, label2; 

   public void init()
   {
      // call label constructor with no text
      label1 = new Label();

      // set the label's text
      label1.setText( "Started with no text" );

      // call label constructor with a string argument
      label2 = new Label( "This is read-only text" );

      // add label components to applet container
      add( label1 );
      add( label2 );
   }

   public void paint( Graphics g )
   {     
      g.drawString( "label1's text is: " + label1.getText(),
         25, 40 );
      g.drawString( "label2's text is: " + label2.getText(),
         25, 55 );
   }
}