Following is a program that combines these components:
import java.applet.Applet;
import java.awt.*;
public class step1 extends Applet{
// Illustrates Additonal User Interface Components
Frame outerBox = new Frame ( );
GridBagLayout gbLayout = new GridBagLayout ( );
GridBagConstraints gbConstraints = new GridBagConstraints ( );
Label title = new Label ( "Personal Information", Label.CENTER);
Panel sexPanel = new Panel ( );
Label sexLabel = new Label ( "Sex:");
CheckboxGroup sexGroup = new CheckboxGroup ( );
Checkbox female = new Checkbox ( "female", sexGroup, false );
Checkbox male = new Checkbox ( "male", sexGroup, false );
Panel colorPanel = new Panel ( );
Label colorLabel = new Label ( "Favorite Color:");
Choice favoriteColor = new Choice ( );
Panel langPanel = new Panel ( );
Label langLabel = new Label ( "Favorite Language:");
List favoriteLang = new List ( 5, false );
TextArea lifeHistory = new TextArea ( "Your Life History", 10, 40 );
Button dialog = new Button ( "Dialog Box" );
public void init ( ){
outerBox.setLayout ( gbLayout );
outerBox.setBackground ( Color.white );
outerBox. setFont (new Font ("Helvetica", Font.PLAIN, 18) );
outerBox.resize (600, 500);
gbConstraints.fill = GridBagConstraints.NONE;
gbConstraints.weightx = 0;
gbConstraints.weighty = 0;
gbConstraints.insets= new Insets ( 10, 0, 20, 0);
addComponent ( outerBox, title, gbLayout, gbConstraints, 0, 0, 2, 1 );
gbConstraints.insets= new Insets ( 0, 0, 10, 10);
gbConstraints.anchor= GridBagConstraints.NORTH;
sexPanel.setLayout ( new GridLayout ( 3, 1 ) );
sexPanel.setBackground ( Color.yellow );
sexPanel.add ( sexLabel );
sexPanel.add ( female );
sexPanel.add ( male );
addComponent ( outerBox, sexPanel, gbLayout, gbConstraints, 0, 1, 1, 1 );
colorPanel.setLayout ( new GridLayout ( 2, 1 ) );
colorPanel.setBackground ( Color.red );
favoriteColor.addItem ( "red" );
favoriteColor.addItem ( "green" );
favoriteColor.addItem ( "blue" );
colorPanel.add ( colorLabel );
colorPanel.add ( favoriteColor);
addComponent ( outerBox, colorPanel, gbLayout, gbConstraints, 0, 2, 1, 1 );
langPanel.setLayout ( new BorderLayout ( ) );
langPanel.setBackground ( Color.green );
favoriteLang.addItem ( "C" );
favoriteLang.addItem ( "C++" );
favoriteLang.addItem ( "Java" );
favoriteLang.addItem ( "Pascal" );
favoriteLang.addItem ( "Perl" );
langPanel.add ( "North", langLabel );
langPanel.add ( "South", favoriteLang);
addComponent ( outerBox, langPanel, gbLayout, gbConstraints, 1, 1, 1, 1 );
dialog.setBackground ( Color.cyan );
addComponent ( outerBox, dialog, gbLayout, gbConstraints, 1, 2, 1, 1 );
gbConstraints.weightx = 1000;
gbConstraints.weighty = 1000;
lifeHistory.setBackground ( Color.lightGray );
addComponent ( outerBox, lifeHistory, gbLayout, gbConstraints, 0, 3, 2, 1 );
outerBox.show( );
} // end init
public void addComponent ( Container cont, Component comp, GridBagLayout gbl, GridBagConstraints gbc, int col, int row, int wid, int hgt ) {
gbc.gridx = col;
gbc.gridy = row;
gbc.gridwidth = wid;
gbc.gridheight = hgt;
gbl.setConstraints ( comp, gbc );
cont.add ( comp );
} // end addComponent
}// end step1