I have several JComponent
s on a JPanel
and I want to disable all of those components when I press a Start button.
At present, I am disabling all of the components explicitly by
component1.setEnabled(false);
:
:
But Is there anyway by which I can disable all of the components at once? I tried to disable the JPanel
to which these components are added by
panel.setEnabled(false);
but it didn't work.
The panel should have a getComponents()
method which can use in a loop to disable the sub-components without explicitly naming them.