Question on JPanel

S

Soundar

If I set a JPanel to not enabled

pane.setEnabled(false);

I am still able to select the components that are the panel's children.
Coming from a VB background, I find this strange. If you disable a
panel, all its children should be automatically disabled. Am I doing
something
wrong? Do I have to disable each child one by one?
 
A

Ann

Soundar said:
If I set a JPanel to not enabled

pane.setEnabled(false);

I am still able to select the components that are the panel's children.
Coming from a VB background, I find this strange. If you disable a
panel, all its children should be automatically disabled. Am I doing
something
wrong? Do I have to disable each child one by one?

Did you add them one by one? Don't you like to have a choice?
 
E

elmar.schraml

You are corredt, the children of the panel are still enabled. In most
cases this is a nuisance, however it does have its uses. For example,
think about a tabbed or scroll-pane where you might want to prohibit
the user from doing anything with the panel itself (scrolling, changing
tabs etc), but still want him to be able to use the components on the
pane.

To reduce the work of disabling all the components one by one, you
could put them into a Collection, and hand this collection off to a
generic function that iterates through the collection and does
often-needed stuff with each component.

regards,
Elmar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top