TabPane, Reiter
Hier ist eine kleine Anwendung, welche Reiter in JavaFX verwendet:
package com.sowas.javawiki.javafx.tabpane; import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Stage; public class TabDemo extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage mainStage) { mainStage.setTitle("TabDemo"); Group root = new Group(); Scene scene = new Scene(root, 240, 100, Color.WHITE); TabPane tabPane = new TabPane(); BorderPane borderPane = new BorderPane(); for (int i = 0; i < 3; i++) { Tab tab = new Tab(); tab.setText("Tab " + i); HBox hbox = new HBox(); hbox.setStyle("-fx-background-color: #fcffcc;"); hbox.getChildren().add(new Label("Tab" + i)); hbox.setAlignment(Pos.CENTER); tab.setContent(hbox); tabPane.getTabs().add(tab); } // Verfügbaren Platz ausnützen: borderPane.prefHeightProperty() .bind(scene.heightProperty()); borderPane.prefWidthProperty() .bind(scene.widthProperty()); borderPane.setCenter(tabPane); root.getChildren().add(borderPane); mainStage.setScene(scene); mainStage.show(); } }
Stichworte:
JavaFX TabPane, Reiter, Tabs