1  /*
  2   *  File:  LabelTest.java
  3   *
  4   *  Create some text labels
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.awt.Label;
 11  import java.awt.Color;
 12  import java.awt.Font;
 13  
 14  public class LabelTest extends java.applet.Applet {
 15  
 16    private Label label0, label1, label2;
 17    private Font f = new Font ("Serif", Font.BOLD, 24 );
 18  
 19    public void init() {
 20  // create each label, set its characteristics and "add" it to the applet
 21  
 22      setBackground( Color.white );
 23  
 24      // By default, a label is left-aligned:
 25      label0 = new Label();
 26      label0.setText( "aligned left   " );
 27      label0.setBackground( Color.yellow );
 28      label0.setFont (f);
 29  
 30      label1 = new Label( "aligned center" );
 31      label1.setAlignment( Label.CENTER );
 32      label1.setForeground( Color.blue );
 33      label1.setFont( new Font( "Monospaced", Font.BOLD, 24 ) );
 34  
 35      label2 = new Label( "   aligned right", Label.RIGHT );
 36      label2.setBackground( Color.yellow );
 37      label2.setFont (f);
 38      
 39      add( label0 ); add( label1 ); add( label2 );
 40    }
 41    
 42  }