Creating a SplitPane

As you experienced in Step 12 of the previous exercise, the SplitPane shown in Figure 6-6 contains a TreeView and a ListView, and its divider can be dragged by the user. The following code snippet, from Listing 6-9, defines and populates the SplitPane in the StarterApp program:

SplitPane splitPane = new SplitPane();
splitPane.getItems().addAll(treeView, listView);

In this case there are two nodes in the SplitPane, which means that there will be just one divider. Note that a SplitPane may have more than two nodes and therefore more than one divider.

In addition to the functionality shown in the previous snippet, a SplitPane may also have its orientation set to VERTICAL, and its dividerPositions set to given percentages of the pane.

Now that you know how to create TreeView, ListView, and SplitPane controls, we move on to the next tab, ScrollPane/Miscellaneous.