Java Code




import java.awt.*;
import javax.swing.*;
public class components2 extends JApplet
{
	JLabel  l_address;
	JTextField  street, city, state, zip;
	JTextArea  ta_message;
	JButton  b_go;
	JCheckBox  cb_lucky,  cb_happy;
	ButtonGroup  bg_mood = new ButtonGroup( );
	JRadioButton  rb_lucky2, rb_happy2;

	public void init( )
	{
		setLayout( new FlowLayout( ) );
		setupAddressInfo( );
		setupSelections( );
		ta_message = new JTextArea( "", 3, 50	);
		add( ta_message );
	}
	public void setupAddressInfo( )	
	{
		l_address = new JLabel( "Address: " );
		street = new JTextField( );
		city = new JTextField(50);
		state = new JTextField( "CO", 2 );
		zip = new JTextField( "80521" );
		add( l_address );
		add( street );
		add( city );
		add( state );
		add( zip );
	}
	public void setupSelections( )    
	{
		b_go = new JButton( "Go!" );
		cb_lucky = new JCheckBox( "Lucky?" );
		cb_happy = new JCheckBox( "Happy?", true );
		bg_mood = new ButtonGroup( );
		rb_lucky2 = new JRadioButton( "Lucky2" );
		rb_happy2 = new JRadioButton( "Happy2", true );
		add( b_go );
		add( cb_lucky );
		add( cb_happy );	

		bg_mood.add( rb_lucky2 );
		bg_mood.add( rb_happy2 );
		add( rb_lucky2 );
		add( rb_happy2 );
	}
}

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