Using Component Methods
Let's suppose, for example, you want to write an applet that uses
a Label whose text is 24 point, SansSerif, bold and blue and whose
background color is yellow.
import java.awt.*;
import java.applet.*;
public class CubScouts extends Applet {
  public void init() {
  
     Label cubScouts = new Label("Cub Scouts!");
     cubScouts.setForeground(Color.blue);
     cubScouts.setBackground(Color.yellow);
     cubScouts.setFont(new Font("Sans", Font.BOLD, 24)); 
     this.add(cubScouts);
     
  }
}
Previous | Next | Top
Last Modified June 26, 1998
Copyright 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu