Source of LabelDemo.java


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