Layout1

Main.java  [download]

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Main extends JFrame {
    public static void main (String [] args) {
	java.awt.EventQueue.invokeLater (new Runnable() {
	    public void run() {
		new Main ();
            }
        });
    }

    public Main () {
	// Window setup
	setLocation (100, 100);
	setSize (500, 500);
	setDefaultCloseOperation (EXIT_ON_CLOSE);

	Container content = getContentPane();
	content.setLayout (new BorderLayout()); //*1 Main content pane, with BorderLayout

	// Text field at top
	JTextField urlField = new JTextField ("http://www.cs.tufts.edu", 30);
	urlField.setBorder (new LineBorder(Color.BLUE, 2));
	content.add (urlField, BorderLayout.NORTH); //*2 JTextField, as NORTH

	// Drawing canvas in middle
	JPanel canvas = new JPanel ();
	canvas.setBorder (new LineBorder(Color.RED, 2));
	content.add (canvas, BorderLayout.CENTER); //*3 JPanel (drawing area), as CENTER

	// Control panel at bottom
	JPanel controls = new JPanel (); //*4 JPanel, as SOUTH, with FlowLayout
	controls.setBorder (new LineBorder(Color.BLUE, 2));
	controls.setLayout (new FlowLayout ()); //*4

	// Put this inside the control panel
	String[] comboStrings = { "Forward", "Back", "Home" };
	JComboBox<String> combo = new JComboBox<String> (comboStrings);
	// For java 1.6 or before, use: "JComboBox" not "JComboBox<String>" in both places
	controls.add (combo); //*5 JComboBox and 2 JButtons

	// These 2 buttons inside control panel also
	JButton reloadButton = new JButton ("Reload");
	controls.add (reloadButton); //*5
	JButton stopButton = new JButton ("Stop");
	controls.add (stopButton); //*5

	// Now plug the control panel into the main frame
	content.add (controls, BorderLayout.SOUTH); //*4

	// Settings panel on right
	JPanel settings = new JPanel (); //*6 JPanel, as EAST, with GridLayout
	settings.setBorder (new LineBorder(Color.BLUE, 2));
	settings.setLayout (new GridLayout (5, 1)); //*6

	// Put these inside the settings panel
	JLabel label = new JLabel ("Settings:");
	settings.add (label); //*7 JLabel and JCheckBox'es
	JCheckBox graphicsCB = new JCheckBox ("Graphics", true);
	settings.add (graphicsCB); //*7
	JCheckBox animationCB = new JCheckBox ("Animation", true);
	settings.add (animationCB); //*7
	JCheckBox javascriptCB = new JCheckBox ("Javascript", false);
	settings.add (javascriptCB); //*7
	JCheckBox cookiesCB = new JCheckBox ("Cookies", false);
	settings.add (cookiesCB); //*7

	// Now plug the settings panel into the main frame
	content.add (settings, BorderLayout.EAST); //*6

	// And show the whole window
	setVisible (true);
    }
}