CardLayout

import java.awt.*;
import java.awt.event.*;

public class Test {
	public static void main (String[] args)
	{
		Win win = new Win("Test Window");
	}
}

class Win extends Frame {
	Win (String name)
	{
					// Frameクラスのコンストラクタ(Windowのタイトルを引き渡す)
		super(name);
					// Windowの大きさ
		setSize(400, 300);
					// レイアウトの変更(水平,垂直ギャップ)
		CardLayout cL = new CardLayout(5, 10);
		setLayout(cL);
					// ボタンの設定
		Button bt1 = new Button("ボタン1");
		Button bt2 = new Button("ボタン2");
		Button bt3 = new Button("ボタン3");
		add("1st", bt1);
		add("2nd", bt2);
		add("3rd", bt3);
		cL.show(this, "1st");   // cL.first(this); と同じ
					// ウィンドウを表示
		setVisible(true);
					// イベントアダプタ
		addWindowListener(new WinEnd());
	}

	/******************************/
	/* 上,左,下,右の余白の設定 */
	/******************************/
	public Insets getInsets()
	{
		return new Insets(35, 10, 10, 10);
	}

	/************/
	/* 終了処理 */
	/************/
	class WinEnd extends WindowAdapter
	{
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	}
}