ActionEvent クラス

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 {

	Button bt;
	TextArea tx;

	/******************/
	/* コンストラクタ */
	/******************/
	Win (String name)
	{
					// Frameクラスのコンストラクタ(Windowのタイトルを引き渡す)
		super(name);
					// レイアウトの変更(行,列,水平ギャップ,垂直ギャップ)
		setLayout(new GridLayout(2, 1, 5, 10));
					// 上のパネル
		Font f1 = new Font("MS 明朝", Font.PLAIN, 30);
						// パネルの追加
		Panel pn1 = new Panel();
		add(pn1);
						// ボタンの追加
		bt = new Button("ボタン");
		bt.setFont(f1);
		bt.addActionListener(this);
		pn1.add(bt);
					// 下のパネル
		Font f2 = new Font("MS 明朝", Font.BOLD, 20);
						// パネルの追加
		Panel pn2 = new Panel();
		add(pn2);
						// テキストエリアの追加
		tx = new TextArea(4, 23);
		tx.setFont(f2);
		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() == bt)   // 以下の方法でも良い
//		if (e.getSource() instanceof Button && e.getActionCommand().equals("ボタン"))
			tx.append("ボタンが押されました\n");
	}

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