Quantcast
Channel: OKWAVE 閲覧数の多い質問(Java/253)【本日】
Viewing all articles
Browse latest Browse all 68675

JAVA Applet for文でのまわし方

$
0
0
JAVA Appletでボタンを押すと色々反応するプログラムを作っています。for文を使わず長々としたプログラムだとコンパイルでき実行できますが、for文を使って簡潔にまとめる表記の仕方がどうもよくわかりません。 /* リスナの登録 */ bt[0].addActionListener(new testActionListener0()); bt[1].addActionListener(new testActionListener1()); bt[2].addActionListener(new testActionListener2()); bt[3].addActionListener(new testActionListener3()); bt[4].addActionListener(new testActionListener4()); bt[5].addActionListener(new testActionListener5()); bt[6].addActionListener(new testActionListener6()); bt[7].addActionListener(new testActionListener7()); bt[8].addActionListener(new testActionListener8()); 上記はfor文でまとめれると思うのですが、どのように表記すれば良いのかわかりません。 for文でくくって、 bt[i].addActionListener~~ とすればそれぞれbt[i]が反応するのはわかりますが、その後の、 ~~(new testActionListener○()); の○の部分にiを入れる場合の表記の仕方がわかりません。もしくはiを入れる事はできないのでしょうか? ※このあとそれぞれのtestActionListener(0~8)のリスナクラスが呼び出されます。 説明が足りないのであれば回答の後、補足しますm(_ _)m

Viewing all articles
Browse latest Browse all 68675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>