JavaFX RadioButton
The RadioButton provides a selectable button where only one from a group may be selected at
one time.
JavaFX Separator
The Separator widget provides either a horizontal or vertical separator that can be used to
partition visual sections into different parts.
JavaFX Slider
The Slider widget provides either a horizontal or a vertical "slider" that can be used to set values.
JavaFX TableView
Every widget set has to have a table and JavaFX is no exception. The table is represented in
JavaFX through the control called "TableView". This class has companion classes to assist with
the description of the table. These include TableColumn and TableCell. We can't describe a
TableView without also including descriptions of these objects.
A TableView contains a list property called "columns" that is the list of columns shown within
the table. Each entry in the list is an instance of a TableColumn object.
The data bound to the table is an instance of an ObservableList. The property used to bind the
data to the table is "items". The elements in the items properties constitute the rows of the table.
When a TableView instance is created, it is associated with a specific class:
TableView<ObjectClass>
This should be read as "We are defining a table where each row in the table is of type
<ObjectClass>".
Now that we have the notion that we can bind a list of objects to a table, how then do these objects
show up? Since we have the notion that a table is an array of table columns, each column is
responsible for displaying its own data. Think of each column being called once for each row in the
table and being responsible for how to visualize the cell that the column maps to the row.
When we define a TableColumn, we are responsible for calling the
setCellValueFactory() method. This method describes how a row passed to the column
will be "examined" and used to populate the appropriate cell.
It will take us some thought to understand this in all of its detail, so we will take our time.
The parameter to the setCellValueFactory() is an instance of the JavaFX Callback
interface. The notion here is that when a table asks a table column to visualize a cell, the table
column will invoke some registered "callback" function to do the job. The Callback interface
has one method called "call()" that will be invoked to do the work.
The declaration of a Callback interface is:
Page 271
Kommentare zu diesen Handbüchern