Javaエバンジェリストがお届けするホットな話題
5分でわかる今週のJava ホットトピック
木曜日 4 05, 2007
今週のJavaクイズ(6):ボタンを押すとどうなる?

今回はJava in the Boxでおなじみの櫻庭さんからの出題です。

ボタンを押すとどうなる?

次のプログラムを実行して、表示されるボタンを押して、なが〜い処理をしている間、ウインドウの表示はどのようになるでしょうか?


public class Monologue implements ActionListener {
private JButton button = new JButton("実行");

public Monologue() {
JFrame frame = new JFrame("Monologue");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button.addActionListener(this);
button.setPreferredSize(new Dimension(100, 26));

frame.add(button);
frame.setSize(100, 70);
frame.setLayout(new FlowLayout(FlowLayout.CENTER));
frame.setVisible(true);
}

public void actionPerformed(ActionEvent event) {
button.setText("処理中...");
button.setEnabled(false);

// なが〜い処理 ^^;;

button.setText("実行");
button.setEnabled(true);
}

public static void main(String[] args) {
new Monologue();
}
}

そのときウインドウの表示がどのようになっているかを次の中からお選びください。

puzzler

投稿されたコメント:

コメント
コメントは無効になっています。
過去の記事
« 12月 2009
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
今日
Click me to subscribeこのブログを購読する(RSS)
検索

リンク
 

Today's Page Hits: 90