I am working on Swing for a while now but never had a situation in practice when I had to call setEnabled(false)
in JPanel
.
Still, I see such code sometimes in some sophisticated gui. But I really don't undarstand why someone wants to use it?
So, please give me some examples of real life common situations when you need to use setEnabled(false)
on JPanel
.
Also in javadoc it says:
Disabling a component does not disable its children.
actually I had a bug because table inside disabled JPanel
didn't show mouse resize cursor when resizing columns. I suspect there are other unpleasant surprises here.
One reason is so that getEnabled() will reflect the correct state. Consider a case where some event handler wants to flag the panel as no longer enabled and it is not prudent at the time of the event to iterate over and disable all child components. Other parts of the app might need to test the state of the panel via getEnabled() to determine what to do at different points in the app.
I personally never had to do this but now that you asked and got me thinking I might use this sometime. Thanks. &&+=1 to the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With