1-16. Adding Tabs to the UI

Problem

You want to create a GUI application with tabs.

Solution

Use JavaFX’s tab and tab pane control. The tab (javafx.scene.control.Tab) and tab pane control (javafx.scene.control.TabPane) classes allow you to place graph nodes in individual tabs.

The following code example creates a simple application having menu options that allow the user to choose a tab orientation. The available tab orientations are top, bottom, left, and right.

    @Override     public void start(Stage primaryStage) {         primaryStage.setTitle("Chapter 1-16 Adding Tabs to a UI");         Group root = new Group();         Scene scene = new Scene(root, 400, 250, Color.WHITE);         TabPane tabPane = new TabPane();         MenuBar menuBar ...

Get JavaFX 2.0: Introduction by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.