Java 根据其他按钮条件设置按钮条件
目前,我的程序有一个选择页面,其中包含4个操作按钮和一个终止按钮,用户点击其中一个操作按钮后,按钮将设置为enabled false,我希望在这4个按钮启用时,将terminate button设置为false模式,但当4个按钮被禁用时,终止按钮将被启用Java 根据其他按钮条件设置按钮条件,java,user-interface,Java,User Interface,目前,我的程序有一个选择页面,其中包含4个操作按钮和一个终止按钮,用户点击其中一个操作按钮后,按钮将设置为enabled false,我希望在这4个按钮启用时,将terminate button设置为false模式,但当4个按钮被禁用时,终止按钮将被启用 do { if (SIG.isEnabled() && RG.isEnabled() && AaCG.isEnabled() && SRG.isEnabled()) { T
do {
if (SIG.isEnabled() && RG.isEnabled() && AaCG.isEnabled() && SRG.isEnabled()) {
Terminate.setEnabled(false);
} else {
Terminate.setEnabled(true);
}
} while (Terminate.equals(false));
}
尝试使用do while循环,但我不知道如何正确编码它将ActionListener添加到按钮。它包含的代码将在每次按下按钮时执行
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Do your check here
if (SIG.isEnabled() && RG.isEnabled() && AaCG.isEnabled() && SRG.isEnabled()){
Terminate.setEnabled(false);
} else {
Terminate.setEnabled(true);
}
}
});
PD:根据,您的变量、字段和方法名称应以小写字母开头,以免与类或接口混淆。如果这个答案对您有效,或者您的任何其他问题中的任何其他答案对您有效,请让人们看到哪个答案解决了问题。