The example puts together several aspects of form building. It uses a placeholder as stand-in for a button bar. The layout of the buttom bar can be shared by forms. It uses a custom ComponentTypeMap with an additional generic mapping to a custom widget (TextField.Highlight). It uses an extended CustomizerMap to enable auto-colon in labels. It shows how to replace components dynamically based on state changes. It explains how to localize applications.
Identify the reusable part(s) of a form
A probable candidate for re-use is the button area of any form: typically it needs to follow a consistent layout across different panels of an application.
Build the layout of the button bar
Here it's simply two buttons - commit and exit. Each id is used at runtime to create an default action with the id as actionCommand. This action is set to the button and customized as defined by its presentation attributes.
Define a generic custom type: TextField.Highlight. Define a (Swing) component class that should be mapped to it. subclass SwingComponentTypeMap to contain the additional mapping. [TBD: support re-mapping at FormBuilder runtime?] Make sure that both the custom ComponentTypeMap and the custom component classes are accessible by FormBuilder and/or your client application.
Subclass LabelCustomizer to turn auto-colon on and register it in the custom ExSwingCustomizerMap. A slight catch is that now we need a custom Label component mapping to explicitly disable the automatic.
Replace components dynamically
Currently, localization is supported at run-time if a application-wide ResourceBundle is registered with the UIManager. The .properties will be found at the same locations as the layout resources. In the example the base resource file is in Esperanto, a localized version in English.
The PresentationManager will try to find an appropriate key/value pair for every PresentationDescription. The format of the key has to be (see de.kleopatra.view.presentation.BundleHandler for details):
[TBD] explain BundleHandler... how to synch Presentation and ResourceBundle.