I have a checkbox and a panel. When the checkbox is checked, I would like for the panel to display. If the user un-checks it, I want the panel to go back to false visibility.
How would I accomplish this?
If you are using Swing as the GUI toolkit. The solution is simple.
Below is the Swing implementation
private JCheckBox box;
box.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
jpanel.setVisible(box.isSelected());
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.