import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.builders.VBoxBuilder; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ScrollPane; import javafx.scene.control.SplitPane; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.control.TabPane.TabClosingPolicy; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; /** * * @author slions */ public class TabPaneTest extends Application { private Scene scene = null; public static void main(String[] args) { Application.launch(TabPaneTest.class, null); } public void start(Stage stage) { scene = new Scene(new Group()); stage.setTitle("TEST"); stage.setWidth(700); stage.setHeight(700); stage.setScene(scene); stage.setVisible(true); final ScrollPane scrollPane = new ScrollPane(); scrollPane.setNode(new Rectangle(500, 500)); Tab tab1 = new Tab(); tab1.setText("tab1"); tab1.setContent(scrollPane); Tab tab2 = new Tab(); tab2.setText("tab2"); tab2.setContent(scrollPane); final TabPane tabPane1 = new TabPane(); tabPane1.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); tabPane1.getTabs().add(tab1); tabPane1.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { tabPane1.setTabMaxWidth(tabPane1.getWidth()); tabPane1.setTabMinWidth(tabPane1.getWidth()); } }); final TabPane tabPane2 = new TabPane(); tabPane2.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); tabPane2.getTabs().add(tab2); tabPane2.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { tabPane2.setTabMaxWidth(tabPane2.getWidth()); tabPane2.setTabMinWidth(tabPane2.getWidth()); } }); SplitPane splitPane = new SplitPane(); splitPane.setPrefSize(500, 500); splitPane.getItems().addAll(tabPane1, tabPane2); ((Group) scene.getRoot()).getChildren().addAll(splitPane); } }