Here is my question. It is said that someone made a checkmark in java, and he uses it in the GUI interface so that the user can select many options. Then the programmer wants to create a button inside the flag so that when the user checks this button, all other parameters will also be checked. And when he canceled this button, of course, all other buttons will be removed. How is this possible in java?
Example:
o1 = new JCheckBox("Option 1"); o2 = new JCheckBox("Option 2"); o3 = new JCheckBox("Option 3"); All = new JCheckBox("All");
.....
CheckBoxHandler listener = new CheckBoxHandler(); All.addItemListener(listener);
......
Suppose the following code is in a class that was created because it implements ItemListener
public class CheckBoxHandler implements ItemListener { public void itemStateChanged(ItemEvent e) { if (e.getSource()==All) if (e.getStateChange()==ItemEvent.SELECTED) { .... <------ (!!!)Here inside I am currently stack and I do not know how to add the correct code in order to have all the other buttons checked. } } }
Any help provided is really appreciated :)
source share