[英]How to tell if an actionevent has been performed for an if statement
我需要知道是否已經執行了特定的動作事件,因為在if語句中,我將執行另一個動作,但是這取決於已經執行了哪個動作事件。
xButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent x9) {
xButton9.setVisible(false);
oButton9.setVisible(false);
nine.repaint();
nine.add(xlabel);
}
} );
oButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent o9) {
xButton9.setVisible(false);
oButton9.setVisible(false);
nine.repaint();
nine.add(olabel);
}
} );
if (ActionEvent 09 has been performed) {
do this stuff
}
您仍然需要在actionPerformed()
方法內部處理該問題,同時還要引用o9
。
oButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent o9) {
xButton9.setVisible(false);
oButton9.setVisible(false);
nine.repaint();
nine.add(olabel);
// whatever else happens when oButton9 is clicked
}
} );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.