You can use the visual editor to bind a Swing JTable to a row data
object.
If you have a JTable in your application, you can bind the table
to be populated by a row data object. For example, you might have a table
in your application where you want to list all company employees, with their
employee ID, last name, and first name. You have available to you a service
(for example, an enterprise bean or a Web service) that returns an array of
employees with a set of properties for each employee. You could bind that
table to the data source row object that represents the data provided by the
service. Each object in the array might include more properties than you want
to display for each employee in the table, so you can specify the properties
that you want to map to columns in your visual table.
When you bind
a JTable to a row data object, the visual editor generates the appropriate
classes and interfaces into a new package (the default package name is jve.generated,
but this can be changed in the Java visual editor preferences), and it creates
a new instance of a JRowTableBinder, which defines the binding between the
JTable and the data object. Some of the capabilities of a JRowTableBinder
include the following:
- It listens for the selected row in the table and provides the single data
object that corresponds to that selected row.
- It provides column sorting.
- It provides property change notification.
- It uses a data source to create the rows.
- It can specify a filter. See Defining
filter binders for tables for more information about using a Swing
property filter to filter a table's contents.
To bind a JTable to a row data object:
The following screen shot shows a table that is bound to a data
object that gets its data from a Web service data source. Notice the line
indicating that the table is bound to the data object. The line also includes
an icon that represents the JRowTableBinder, which is used by the table as
its binding model.
