/**
 * This class defines the main frame for the Layout manager
 * program
 */
import java.awt.*;
import javax.swing.*;
public class MainFrame extends JFrame {
	// define north panel and components
	JPanel northPanel = new JPanel ( );
	JButton resetButton = new JButton ( "Reset" ) ;
	JButton exitButton = new JButton ( "Exit" ) ;
	
	// define east panel and components
	JPanel eastPanel     = new JPanel ( ) ;
	Checkbox northCheck  = new Checkbox ( "North" ) ;
	Checkbox southCheck  = new Checkbox ( "South" ) ;
	Checkbox westCheck   = new Checkbox ( "West" ) ;
	Checkbox centerCheck = new Checkbox ( "Center " ) ;
	
	// define west panel and components
	Panel westPanel = new Panel ( ) ;
	CheckboxGroup colorGroup = new CheckboxGroup ( ) ;
	Checkbox redCheck        = new Checkbox ( "Red", false, colorGroup ) ;
	Checkbox greenCheck      = new Checkbox ("Green", false, colorGroup) ;
	Checkbox blueCheck       = new Checkbox ("Blue", false, colorGroup) ;
	Checkbox blackCheck      = new Checkbox ("Black", true, colorGroup) ;
	
	// define center panel and components
	Panel centerPanel   = new Panel ( ) ;
	Button northButton  = new Button ( "North" ) ;
	Button southButton  = new Button ( "South" ) ;
	Button eastButton   = new Button ( "East" ) ;
	Button westButton   = new Button ( "West" ) ;
	Button centerButton = new Button ( "Center" ) ;
	
	// define south panel and components
	Panel southPanel = new Panel ( ) ;
	TextField northStatus = new TextField ( 10 ) ;
	TextField westStatus = new TextField ( 10 ) ;
	TextField centerStatus = new TextField ( 10 ) ;
	
/**
 * The constructor function
 */

public MainFrame ( String str ) {
super ( str ) ;
// add the components to each panel and sets its format
northPanel.setLayout ( new FlowLayout(FlowLayout.CENTER) ) ;
northPanel.add ( resetButton ) ;
northPanel.add ( exitButton ) ;
eastPanel.setLayout ( new GridLayout ( 4,1 ) ) ;
eastPanel.add (northCheck );
eastPanel.add (southCheck );
eastPanel.add (westCheck );
eastPanel.add (centerCheck );
westPanel.setLayout ( new GridLayout ( 4,1 ) ) ;
westPanel.add ( redCheck ) ;
westPanel.add ( greenCheck ) ;
westPanel.add ( blueCheck ) ;
westPanel.add ( blackCheck ) ;
centerPanel.setLayout ( new BorderLayout ( ) ) ;
centerPanel.add ( northButton, "North") ;
centerPanel.add (southButton, "South") ;
centerPanel.add (eastButton, "East") ;
centerPanel.add (westButton, "West") ;
centerPanel.add (centerButton, "Center") ;
southPanel.setLayout ( new FlowLayout(FlowLayout.CENTER ) ) ;
southPanel.add ( northStatus ) ;
southPanel.add ( westStatus ) ;
southPanel.add ( centerStatus ) ;
 
// set up panels in frame
this.getContentPane ( ).setLayout ( new BorderLayout ( ) ) ;
getContentPane ( ).add ( northPanel, "North" ) ;
getContentPane ( ).add ( southPanel, "South" ) ;
getContentPane ( ).add ( eastPanel, "East" ) ;
getContentPane ( ).add ( westPanel, "West" ) ;
getContentPane ( ).add ( centerPanel, "Center" ) ;
}
}