[英]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.