Suppose I have a hierarchy like this:
JPanel panel1; JCheckBox cb1; JCheckBox cb2; JRadioButton rb1; JRadioButton rb2; ...
I have a condition where I want separate groups of controls inside the panel to be enabled / disabled. It works great. (for example, turn on cb1 and cb2 when one condition is true, turn them off when it is false.)
I would like to disable and enable the entire panel again. If I call panel1.setEnabled(false) , this does not work, it disables the panel, but does not affect its children.
If I list the children of the panel and call setEnabled(false) for each of them, this will work, but then I will have to keep the child state on when the panel is turned on again.
Is there an easier way?
source share