The crux of Morten
1e00
’s problem is he has a ton of Swing controls whose enabled state needs to be managed, but no good solution for grouping these controls together into logical chunks that can be managed as a group.
This post has made its way to the Spring-Rich forums. Keith Donald comments on two ways that Spring Rich addresses this problem:
1. We have a "Guarded" interface, consisting of setEnabled(boolean), that almost all "control factories" implement--allowing the easy enablement of compound controls in one call. A control factory is any object that encapsulates the creation of one or more swing controls: things like dialogs, wizards, forms, commands, etc (we much favor composition over inheritence.) There is a "GuardedGroup" helper which makes it easy to adapt any logical group of JComponents to the Guarded interface.
2. Our "command" framework, which adds considerably more power to Swing's action concept, has two major constructs: ActionCommands and CommandGroups -- both "Guarded", and both factories for the underlying gui controls (the former, producing actionable buttons, menu items, check boxes, or radio buttons---the latter, producing menus, button bars, tool bars, status bars, and popups) Calling setEnabled(boolean) on a root command object automatically updates the enabled state for all controls bound to that command. Some of the design here was notably inspired by the work of Andrew Pietsch’s GUI Commands, a quality project that also greatly improves on Swing’s base action framework.