確認テスト(12/16)

氏名[

部品のクラスでアクション処理を行う例です。 以下の設問に答えなさい。
このプログラムでは、一方のボタンのアクション処理によって、 他のボタンを表示したり画面から消去したりします。 空欄を埋めてプログラムを完成させなさい。


  1. アプレットのクラスの名前は?

  2. アクション処理を組み込んだ新しいクラスの名前は?

  3. アクション処理を組み込んだ新しいクラスのスーパークラスの名前は?

  4. アクション処理を組み込んだ新しいクラスのコンストラクタの引数の個数は?

  5. アプレットのソースの中で、 アクション処理を組み込んだオブジェクトの名前は?

  6. アプレットのソースの中で、 アクション処理によってコントロールされるオブジェクトの名前は?

  7. アクション処理を組み込んだ新しいクラスのソースの中で、 アクション処理によってコントロールされるオブジェクトの名前は?

  8. このアプレットは、どんなふうにレイアウトされますか? 概略図を描きなさい。



import java.awt.*;
import java.applet.Applet;

/** 他のコンポーネントの表示をコントロールする ShowControl クラス */

class ShowControl extends Checkbox {

   /** コントロールを受けるコンポーネント */

      Component sheep;

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

      ShowControl( String label, Component sheep ) {
           super(label);
           this.sheep = sheep;
      }

   /** 独自のアクション処理 */

      public boolean action( Event evt, Object obj ) {

            if( getState() ) sheep.hide();
            else             sheep.show();

            return true;
      }
}

/** アクションの処理をテストするアプレット ButtonControl クラス */

public class ButtonControl extends Applet {


   /** インターフェイスの部品の宣言 */ 
      public Button button;
      public ShowControl showControl;

   /** 初期設定のメソッド */

      public void init() {

           button = new Button( "I am Controled by Anyone." );
           showControl = new ShowControl( "Show/Hide", button );
           add( showControl );
           add( button );
      }
}