简体   繁体   English

如果选择了“全部”选项,如何确保其他选项不运行?

[英]if an option “ALL” is selected, how do I make sure other options does not run?

so here's my question... I am using java eclipse. 所以这是我的问题...我正在使用java eclipse。 I have this few options designed to allow the user to tick in the checkbox of the java GUI. 我设计了这几个选项,以允许用户在Java GUI的复选框中打勾。 But I have this one option that is "All", how can I ensure that when the "All" option is ticked, the other options that is ticked will not run except for this "All" option? 但是我有一个选项为“全部”,如何确保在选中“所有”选项时,除此“所有”选项之外,其他选项都不会运行?

What can I do to solve this problem?? 我该怎么做才能解决这个问题?

Here's my java coding.. 这是我的Java编码。

btnStart.addActionListener(new ActionListener()
    {
        public void actionPerformed(ActionEvent args)
        {
            //if checkbox_4 (ALL) is being selected, the other checkboxes will be disabled/not running so there will not be overlapping..
            if(checkbox_4.isSelected())
            {
                try
                {   
                    String command = "cmd /c start /wait "+DetectDrive+"\\All.bat";
                    Process p = Runtime.getRuntime().exec(command);
                    p.waitFor();
                } 
                catch (IOException | InterruptedException e1)
                {
                    e1.printStackTrace();
                }
            }

            if(checkbox.isSelected())
            {
                try
                {   
                    String command = "cmd /c start /wait "+DetectDrive+"\\1.bat";
                    Process p = Runtime.getRuntime().exec(command);
                    p.waitFor();
                } 
                catch (IOException | InterruptedException e1)
                {
                    e1.printStackTrace();
                }

            //so on and so forth..
            }
        }
    }

You should use setEnabled(false) on all the other checkboxes. 您应该在所有其他复选框上使用setEnabled(false)

Be sure to re-enable them once the "all" checkbox is unselected. 取消选中“所有”复选框后,请务必重新启用它们。

just use IF ELSE statement. 只需使用IF ELSE语句即可。

if the checkbox_4 is selected, then run it. 如果选择了checkbox_4,则运行它。 else check if other boxes are ticked, if yes. 否则,请检查是否勾选了其他框。 run it. 运行。 short and simple. 简短。

暂无
暂无

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

相关问题 如何确保在 Java 中只选择了一个 JRadioButton? - How Do I Make Sure Only One JRadioButton Is Selected In Java? java有条件的我如何确保它检查所有的if语句 - java conditional how do I make sure it checks all if statements 如何显示微调器中的选项,将其选中后将其另存为整数变量? - How do I show options in a spinner that, when selected, save that option as an integer variable? 如何确保在 java 中一个线程始终先于其他线程运行? 给定两个线程。 我需要确保线程 1 始终领先于线程 2 - How do I ensure that one thread always run ahead of other in java? Given two threads. I need to make sure that Thread 1 always leads Thread 2 如何确定按钮已选中? - How do I make sure that the button is checked? 如何确保4个随机变量永远不相等? - How do I make sure 4 random variables never equal each other? 如何确保我将所有小数点后的所有数字从Excel导出到MySQL - How do I make sure I get all the digits past the decimal out of Excel and into MySQL 如何确保 Java 线程永远不会运行无限循环? - How do I make sure that a Java thread will never run an infinite loop? 在JBoss应用程序服务器中,如何确保部署中的所有模块对jar库使用相同的Classloader? - In JBoss application server, how do I make sure that all modules in a deployment use the same Classloader for a jar library? 当选择所有选项时,如何使jButton改变它的颜色? - How to make a jButton change it's color when all the options are selected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM