表示,非表示,移動,サイズ変更

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

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

/*******************/
/* クラスWinの定義 */
/*******************/
class Win extends Frame implements ActionListener, ComponentListener {

	Button bt1, bt2;
	TextArea tx;
	Test_Wn wn;

	/******************/
	/* コンストラクタ */
	/******************/
	Win (String name)
	{
					// Frameクラスのコンストラクタ(Windowのタイトルを引き渡す)
		super(name);
					// レイアウトの変更(行,列,水平ギャップ,垂直ギャップ)
		setLayout(new GridLayout(2, 1, 5, 10));
		Font f = new Font("MS 明朝", Font.BOLD, 20);
					// Windowの生成
		wn = new Test_Wn("Window");
		wn.addComponentListener(this);
					// 上のパネル
						// パネルの追加
		Panel pn1 = new Panel();
		add(pn1);
						// ボタンの追加
		bt1 = new Button("表示");
		bt1.setFont(f);
		bt1.addActionListener(this);
		pn1.add(bt1);

		bt2 = new Button("非表示");
		bt2.setFont(f);
		bt2.addActionListener(this);
		pn1.add(bt2);
					// 下のパネル
						// パネルの追加
		Panel pn2 = new Panel();
		add(pn2);
						// テキストエリアの追加
		tx = new TextArea(4, 23);
		tx.setFont(f);
		pn2.add(tx);
					// Windowの大きさ
		setSize(300, 300);
					// ウィンドウを表示
		setVisible(true);
					// イベントアダプタ
		addWindowListener(new WinEnd());
	}

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

	/******************************/
	/* ボタンが押されたときの処理 */
	/******************************/
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == bt1)
			wn.setVisible(true);
		if (e.getSource() == bt2)
			wn.setVisible(false);
	}

	/********************/
	/* Windowの状態変化 */
	/********************/
	public void componentHidden(ComponentEvent e)
	{
		tx.append("非表示になりました\n");
	}
	public void componentMoved(ComponentEvent e)
	{
		tx.append("移動しました\n");
	}
	public void componentResized(ComponentEvent e)
	{
		tx.append("大きさが変わりました\n");
	}
	public void componentShown(ComponentEvent e)
	{
		tx.append("表示されました\n");
	}

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

class Test_Wn extends Frame {
	Test_Wn(String name)
	{
		super(name);
		setSize(220, 100);
	}
}