简体   繁体   English

根据其他按钮条件设置按钮条件

[英]set button condition based on other button condition

currently my program have a selection page which contain 4 action button with one terminate button and after the user click into one of the action button the button will set enabled (false) and i want to set terminate button in false mode when those 4 buttons are enabled but when 4 button is diabled than the terminate button will be enabled 当前,我的程序有一个选择页面,其中包含4个操作按钮和一个终止按钮,并且当用户单击其中一个操作按钮后,该按钮将设置为启用(错误),而当这4个按钮为启用,但是当禁用4个按钮时,将启用终止按钮

do {
    if (SIG.isEnabled() && RG.isEnabled() && AaCG.isEnabled() && SRG.isEnabled()) {
        Terminate.setEnabled(false);
    } else {
        Terminate.setEnabled(true);
    }
} while (Terminate.equals(false));
}

try to use do while loop but i dont know how to code it properly 尝试使用do while循环,但我不知道如何正确编码

Add an ActionListener to the button. ActionListener添加到按钮。 The code it contains will be executed everytime the button is pressed. 每按一次该按钮,将执行其中包含的代码。

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: According to the Java Naming Conventions , your variable, fields and method names should start with a lowercase letter, to not confuse them with a Class or an Interface. PD:根据Java命名约定 ,您的变量,字段和方法名称应以小写字母开头,以免将它们与类或接口混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM