Click the Bindings tab in the editor to created and edit data bindings.

image

image

Swing uses simple bindings between targets and models.

Target & Model Types

Two types of targets and models are supported:

  • image Beans: any field of the current compilation unit may be selected. The filter field above the list can be used to filter the list of beans. The image clear button can be used to clear the filter and restore the full list. Beans are the primary data source for bindings (usually the model). Any property of the Bean may be observed. Individual beans may also be expanded to reveal their direct sub properties.
    image image

  • image Widgets: any widget in the current compilation unit may be selected. If a widget is not a field, it will be converted to a field automatically. The filter field above the list can be used to filter the list of widgets. The image clear button can be used to clear the filter and restore the full list. Any property of the Widget may be observed.
    image image

Properties

When any Target or Model object is selected, its properties (bean fields or standard Swing widget properties) are shown in the associated Properties list. Properties may be expanded to show their nested attributes. A drop down filter menu is available to filter the Property list by type and hide or show the advanced properties. Supported filters are String, Boolean, Numbers, Color, Font and Image.

image image image image image

New Swing Bindings

New bindings are created by selecting a Target, a Target Property, a Source, a Source Property and clicking the image Bind button. When creating a binding, the update strategy from target to model and model to target may be specified as well as any strategy-specific properties (converter and validator).

image

When the Target or Model is a Text widget and the text property is selected, the triggering event may be specified as Swing.Modify, Swing.FocusOut or Swing.NONE.

image

Predefined update value strategies - READ_ONCE, READ and READ_WRITE - may be selected.

image

When binding to a <EL Expression>, a text field is provided where the expression may be entered.

image

When binding a JList to a collection of model objects, the detail of the model (what is shown in the list) can be specified.

image

When binding a JTable to a collection of model objects, column bindings may be added for each model object property.

image image

Existing Swing Bindings

At the top of the page, existing Bound Properties are listed. The Target and Model are shown as well as the Strategy and the Binding variable name.

image

Clicking the image Edit button or Edit menu opens the Edit Binding dialog where the update strategy, converter and validator may be modified.

image

The image Delete button or Delete menu is used to delete the selected bound property while the image Delete All button or Delete All menu is used to delete all of the bound properties.

The image Move Up and image Move Down buttons and menus are used to change the order of the bindings while the image Goto Definition button and menu are used to jump to the generated code for the binding.

Source

As bindings are created or edited on the Bindings tab, the necessary data binding code is generated which may then be seen in the Source view. An initDataBindings() method is created, if it does not already exist and a call to that method is added to the end of the widget creation process.

Within the initDataBindings() method, any needed bean properties are created followed by the creation of each binding.

image

Warning
do not edit the initDataBinding() method by hand (without carefully matching the code generation pattern used by the tool) as it will be regenerated in its entirety any time the tool needs to add, remove or update a data binding.