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

public class LayoutExample {
  public static void main(String[] argv) {
    JFrame f = new JFrame("Layout example");
    f.getContentPane().setLayout(new BorderLayout());
    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new FlowLayout());
    JButton b1 = new JButton("Button 1");
    b1.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) {
	  JColorChooser.showDialog(topPanel, "Choose a color", Color.red);
	}
      });
    JButton b2 = new JButton("Button 2");
    JButton b3 = new JButton("Button 3");
    JButton b4 = new JButton("Button 4");
    topPanel.add(b1, BorderLayout.NORTH);
    topPanel.add(b4, BorderLayout.NORTH);
    f.getContentPane().add(topPanel, BorderLayout.NORTH);
    f.getContentPane().add(b2, BorderLayout.WEST);
    f.getContentPane().add(b3, BorderLayout.CENTER);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
  }
}
