Java Reference
In-Depth Information
Once you have created a column, you'll notice the
setProperty()
method,
which is responsible for calling the person
Bean
's property. When the list of employ-
ees is put into the
TableView
, it will know how to pull the properties to be placed in
each cell in the table.
Last is the implementation of the selection listener on the
ListViewer
in
JavaFX, called a selection item property (
selectionItemProperty
). Create and
add a
ChangeListener
to listen to selection events. When a user selects a boss, the
TableView
is cleared and populated with the boss' employees. Actually it is the ma-
gic of the
ObservableList
that notifies the
TableView
of changes. To populate
the
TableView
via the
teamMembers
(
ObservableList
) variable, use this
code:
teamMembers.clear();
teamMembers.addAll(observable.getValue().employeesProperty());
14-14. Organizing the UI with Split Views
Problem
You want to split up a GUI screen by using split divider controls.
Solution
Use JavaFX's split pane control. The
javafx.scene.control.SplitPane
class is a UI control that enables you to divide a screen into frame-like regions. The
split control allows users to move the divider between any two split regions with the
mouse.
Shown here is the code used to create the GUI application that utilizes the
javafx.scene.control.SplitPane
class. That class divides the screen into
three windowed regions. The three windowed regions are a left column, an upper-right
region, and a lower-right region. In addition,
Text
nodes are added to the three re-
gions.
public void start(Stage primaryStage) {
primaryStage.setTitle("Chapter 14-14 Organizing UI
with Split Views");