Question

I'm just trying to work out the best way to replicate a pretty useful feature of Windows' Forms.Panel in Java. Basically, when you disable a Windows Forms.Panel, all child control's are set to disabled too. However, their enabled property is preserved such that, when the the Panel is enabled again, any child control that was disabled before the Panel was disabled, remains disabled.

I can add a property listener for a JPanel to be triggered when it's enabled property is changed and then cycle through all the JPanel's components and set them to disabled, but this wont preserve the component's enabled properties.

Any suggestions?

Was it helpful?

Solution

A more complex solution can be found in the Disabled Panel entry. Internally it uses a collection as suggested by mlk to track the components that where enabled. Even if you don't like the proposed solution you can still use the Swing Utils class to easily get all the components on the panel.

OTHER TIPS

Store the disabled components in a collection and check this collection when re-enabling them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top