/* * File: LabelTest.java * * Create some text labels * * Copyright: Northeast Parallel Architectures Center * */ import java.awt.Label; import java.awt.Color; import java.awt.Font; public class LabelTest extends java.applet.Applet { private Label label0, label1, label2; private Font f = new Font ("Serif", Font.BOLD, 24 ); public void init() { // create each label, set its characteristics and "add" it to the applet setBackground( Color.white ); // By default, a label is left-aligned: label0 = new Label(); label0.setText( "aligned left " ); label0.setBackground( Color.yellow ); label0.setFont (f); label1 = new Label( "aligned center" ); label1.setAlignment( Label.CENTER ); label1.setForeground( Color.blue ); label1.setFont( new Font( "Monospaced", Font.BOLD, 24 ) ); label2 = new Label( " aligned right", Label.RIGHT ); label2.setBackground( Color.yellow ); label2.setFont (f); add( label0 ); add( label1 ); add( label2 ); } }