If you have fields in the UI class that you want bound to some data in a JavaBean class, IntelliJ IDEA provides a
special Data Binding Wizard.
This wizard helps generate
getData
and
setData
methods for the fields in a UI class that are bound to components in a GUI form.
You can create data binding to an existing bean class, or create a new
bean class on the fly using the wizard.
For example, suppose you have some JTextField components on a GUI form that are bound to fields in a UI
class, and you want the value of their text properties bound to some data
in a JavaBean class. Instead of editing the UI class, creating
getData
and
setData
methods for the fields, being careful to specify the fully qualified name of
the correct bean class and importing the required package, just use the Data Binding Wizard.
Note
The GUI form must be bound to a class, and the GUI components must be bound
to some fields in the class before running the Data Binding Wizard.
When you finish the wizard, the specified accessor methods are written to the form's class according
to the options you specified in the wizard. Import statements are generated in the class as necessary.
Once components have been bound to data, you can invoke the Data Binding Wizard again, in which case you
are
presented with options to either remove the data binding, or bind to a different bean. If you choose the
latter
option, the wizard enables you to select or create the bean class for the data binding. The source code
of the
UI class (including imports) is modified according to your choices and specifications.
Tip
If you look at the code and discover you made a mistake, you can use Undo to
revert the code to its former state.