Reputation: 111
How can I uncheck the JCheckBox
?
I am making a GUI in which I want to uncheck the selected check box after click on the "Add" button. What I am doing when I select the check box and display name will be add in to array list Panel.Arr
. After click on Add button selected check boxes added in to the "List of the image to be imported panel".
I want that when selected check box add in to "Image to be imported panel", the selected check box becomes unchecked/disabled. So that user will not select again once its add in to the "Image to be imported panel"
I am pasting the snapshot of my GUI so that you can understand easily.
and I am also pasting my checkbox display code and add button code //checkbox display code
{
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
}
//Add button code
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);
Upvotes: 1
Views: 2446
Reputation: 110
Not sure if this is what you want, you can use t.setSelected(false)
. That'll make the JCheckBox unchecked.
Upvotes: 1