[英]How to tell if an actionevent has been performed for an if statement
I need to know if a specific action event has been performed because in the if statement I will have another action be performed, but it depends on which action event(s) have already been performed. 我需要知道是否已经执行了特定的动作事件,因为在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
}
You need to handle that inside of your actionPerformed()
method, while you still have a reference to o9
. 您仍然需要在
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.