ButtonAndText.java



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

/** ボタンとテキスト・エリアを含む ButtonAndText クラス */

public class ButtonAndText extends Frame implements ActionListener {

   /** 内部のコンポーネント */

      public Button button;
      public TextArea textArea;

   /** コンストラクタ */

      ButtonAndText( String title, String label ) {

            super( title );

            button = new Button( label );
            add( "North", button );
       // ボタンからのアクションを受け取る
            button.addActionListener( this );

            textArea = new TextArea( 10, 20 );
            add( "Center", textArea );
            pack();
      }

   /** アクションの処理を行う(新しいイベントモデル) */

      public void actionPerformed( ActionEvent evt ){

          /* このクラスでは処理の内容は定義しない。 */
      }
}