Java Code

import java.awt.*;
import javax.swing.*;
public class AddressTest extends JApplet
{
	HomeAddress home;
	SchoolAddress school;
	BillingAddress billing;
	public void init( )
	{
		setLayout( new GridLayout( 1, 3 ) );
		home = new HomeAddress( );
		school = new SchoolAddress( );
		billing = new BillingAddress( );
		add( home );
		add( school );
		add( billing );
	}
}

import java.awt.*; import javax.swing.*; public class AddressFields extends JPanel { // instance variables JLabel name, street, city, state, zip; JTextField tf_name, tf_street, tf_city, tf_state, tf_zip; public AddressFields( ) // constructor { // initialize the instance variables name = new JLabel( "Name:", JLabel.RIGHT ); street = new JLabel( "Street:", JLabel.RIGHT ); city = new JLabel( "City:", JLabel.RIGHT ); state = new JLabel( "State:", JLabel.RIGHT ); zip = new JLabel( "Zip:", JLabel.RIGHT ); tf_name = new JTextField( 20 ); tf_street = new JTextField( 20 ); tf_city = new JTextField( 20 ); tf_state = new JTextField( 20 ); tf_zip = new JTextField( 20 ); // add to the panel setLayout( new GridLayout(5, 2) ); add( name ); add( tf_name ); add( street ); add( tf_street ); add( city ); add( tf_city ); add( state ); add( tf_state ); add( zip ); add( tf_zip ); } }
import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class HomeAddress extends AddressFields { Border titled; JCheckBox post, pkg; public HomeAddress( ) { setLayout( new GridLayout( 6,2 ) ); init( ); } public void init( ) { titled = new TitledBorder( "Home Address" ); setBorder( titled ); setupMailOptions( ); } public void setupMailOptions( ) { post = new JCheckBox( "Post" ); pkg = new JCheckBox( "Packages" ); add( post ); add( pkg ); } }
import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class SchoolAddress extends AddressFields { Border titled; JTextField tf_phone; JLabel start, end; JTextField tf_start, tf_end; public SchoolAddress( ) { setLayout( new GridLayout( 7,2 ) ); init( ); } public void init( ) { titled = new TitledBorder( "School Address" ); setBorder( titled ); start = new JLabel( "Start date:", JLabel.RIGHT ); end = new JLabel( "End date:", JLabel.RIGHT ); tf_start = new JTextField( 20 ); tf_end = new JTextField( 20 ); add( start ); add( tf_start ); add( end ); add( tf_end ); } }
import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class BillingAddress extends AddressFields { Border titled; JLabel phone; JTextField tf_phone; public BillingAddress( ) { setLayout( new GridLayout( 6,2 ) ); init( ); } public void init( ) { titled = new TitledBorder( "Billing Address" ); setBorder( titled ); phone = new JLabel( "Phone", JLabel.RIGHT ); tf_phone = new JTextField( 20 ); add( phone ); add( tf_phone ); } }

©2007-2009 by E.S.Boese. All Rights Reserved