Java Reference
In-Depth Information
Figure 6-15.
3.
Click the Exit button to close the application.
Now we need to perform steps F and G.
4.
Add the following statement to create a CheckboxGroup object and class variable:
private CheckboxGroup cbg = new CheckboxGroup();
Can you explain what this statement does?
5.
Add each of the following statements after the appropriate checkbox's
setBounds statement:
empAppCB.setCheckboxGroup(cbg);
shipAppCB.setCheckboxGroup(cbg);
sortAppCB.setCheckboxGroup(cbg);
6.
Save the source and run CBTestApp as a Java application.
Notice that the checkboxes are now round, indicating they are in a checkbox group.
7.
Click the shipAppCB checkbox, then empAppCB, then sortAppCB, then the Exit button.
Notice that clicking one checkbox unchecks the previously clicked checkbox and that the itemStateChanged
method is being called each time any checkbox is clicked.
Search WWH ::




Custom Search