有可能識別wht btn是否被一個唯一的eventListener按下?什麼按鈕被按下java
我想這代碼,但
ActionListener one = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (gr1.getCounter1() < 5) {
gr1.setCounter1(gr1.getCounter1() + 1);
if (arraybtn[1].isSelected())
test1.setIcon(play1a);
if (arraybtn[2].isSelected())
test1.setIcon(play1b);
if (arraybtn[3].isSelected())
test1.setIcon(play1c);
if (arraybtn[4].isSelected())
test1.setIcon(play1d);
if (arraybtn[5].isSelected())
test1.setIcon(play1e);
} else {
pn5.setText("No more cards");
}
}
};
由於沒有工作,!
所以你會得到 如果(arraybtn [1] .equals(e.getSource())):-) – hauntsaninja 2011-02-06 16:45:12
謝謝,完美 – anvd 2011-02-06 16:46:59