如何取消选中JCheckBox
?
我正在制作一个 GUI,我想在单击“添加”按钮后取消选中选中的复选框。当我选中复选框时我在做什么,显示名称将添加到数组列表中Panel.Arr
。单击添加按钮后,选中的复选框添加到“要导入的图像列表面板”中。
I want that when selected check box add in to "Image to be imported panel", the selected check box becomes unchecked/disabled. 因此,一旦将其添加到“要导入的图像面板”中,用户就不会再次选择
我正在粘贴我的 GUI 的快照,以便您可以轻松理解。
我还粘贴了我的复选框显示代码并添加按钮代码//复选框显示代码
{
int space=30;
// create a check button (for selection) for each target resource
for (int i=0; i < images.size(); i++) {
ResourceListObject resource = images.get(i);
// create the radio button for this target
t = new JCheckBox(resource.getName() + ", " + resource.getOID());
t.addActionListener(this);
t.setBackground(SystemColor.menu);
t.setName(""+i);
t.setActionCommand(resource.getName()+"_"+resource.getOID());
t.setBounds(13, space,355, 23);
t.setVisible(true);
panel.add(t);
space=space+25;
// add the virtual target to the target group, then to the panel
}
//添加按钮代码
JButton btnNewButton = new JButton("Add >>");
btnNewButton.setBounds(437, 312, 100, 23);
btnNewButton.addActionListener(new ActionListener() {
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent arg0)
{
Volume_ID_Image_tmp = restEngine.getimageContent(Panel.Arr);
try {
@SuppressWarnings("unused")
ImportImagePanel jsonobj = new ImportImagePanel(Volume_ID_Image_tmp,panel_1,"add");
} catch (IOException e) {
e.printStackTrace();
}
Volume_ID_Image.addAll(Volume_ID_Image_tmp);
Volume_ID_Image_tmp.clear();
}
});
frmToolToMigrate.getContentPane().add(btnNewButton);