Applet run with a width of 500:



Applet run with a width of 200:


Java Code



 import java.awt.*;
 import javax.swing.*;
	
 public class JLabelEx1 extends JApplet
 {
        JLabel  label1, label2;

   public void init( ) 
   {
        setLayout(new FlowLayout( )  );

        // Create the first label.
        label1 = new JLabel( "Java is fun to learn" );
	 
        // Create the other label
        label2 = new JLabel( "But I like skiing too!" );
	
        // Add the labels.
        add( label1 );
        add( label2 );
    }
 }

Back to Code Examples
©2006- by E.S.Boese. All Rights Reserved