Source of LabelDemo.java


  1: //LabelDemo.java
  2: 
  3: import javax.swing.JApplet;
  4: import javax.swing.JLabel;
  5: import java.awt.Color;
  6: import java.awt.Container;
  7: import java.awt.FlowLayout;
  8: 
  9: /**
 10:  * An applet that uses a label to display text.
 11:  */
 12: public class LabelDemo extends JApplet
 13: {
 14:     public void init()
 15:     {
 16:         Container contentPane = getContentPane();
 17:         contentPane.setBackground(Color.WHITE);
 18: 
 19:         //Create labels:
 20:         JLabel label1 = new JLabel("Hello ");
 21:         JLabel label2 = new JLabel("out there!");
 22: 
 23:         //Add labels:
 24:         contentPane.setLayout(new FlowLayout());
 25:         contentPane.add(label1);
 26:         contentPane.add(label2);
 27:     }
 28: }