Java Code

import java.awt.*;
import javax.swing.*;
public class Nesting extends JApplet
{
    JLabel title, agree;
    JButton yes;
    JTextArea msg;
    public void init( )
    {
			// set layout to BorderLayout
    	setLayout( new BorderLayout( ) );
			// create components
    	title = new JLabel( "I'm a Star!", JLabel.CENTER);
    	agree = new JLabel( "Agree? " );
    	yes = new JButton( "Yes!" );
    	msg = new JTextArea( 2,10 );
			// create nested panel
		JPanel pane = new JPanel( new FlowLayout( ) );
		pane.add( agree );
		pane.add( yes );
			// add panel to West side
		add( pane, BorderLayout.WEST );
			// add title to North
		add( title, BorderLayout.NORTH );
			// add text area to East side
		add( msg, BorderLayout.EAST );
    }
}

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