Reputation: 93
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?
Upvotes: 0
Views: 1229
Reputation: 2641
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());
}
});
Upvotes: 1