Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8172697

TabPane doesn't resize properly based on the content of its tabs

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      If you have a VBox as the content of a Tab and you add elements to the VBox the TabPane doesn't resize until one switches to another Tab

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      When running the below chunk, clcking on the button on the second tab does not resize the tab pane until one switches to tab1


      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TabPaneBug extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          TabPane tabPane = new TabPane();

          @Override
          public void start(Stage primaryStage) {

              ScrollPane root = new ScrollPane();
              HBox spContent = new HBox(10);
              root.setContent(spContent);
              
              

              tabPane.setStyle("-fx-border-color:red");
              spContent.getChildren().add(tabPane);

              Tab t1 = new Tab();
              tabPane.getTabs().add(t1);
              t1.setText("Tab 1");
              HBox tab1Content = new HBox();
              t1.setContent(tab1Content);

              Tab t2 = new Tab();
              tabPane.getTabs().add(t2);
              t2.setText("Tab 2");
              VBox tab2Content = new VBox();
              t2.setContent(tab2Content);

              buildTabPane(tab1Content, tab2Content);

              Scene scene = new Scene(root);
              primaryStage.setScene(scene);
              primaryStage.setHeight(800);
              primaryStage.show();
              
      // tabPane.tabMaxHeightProperty().bind(tab1Content.heightProperty());
      // tabPane.tabMinHeightProperty().bind(tab1Content.heightProperty());
          }

          private void buildTabPane(Pane tab1Content, Pane tab2Content) {

              Button b2 = new Button("Click");
              tab2Content.getChildren().addAll(b2);
              b2.setOnAction(e -> {
                  tab2Content.getChildren().add(new Label("Toooo"));
                  tab2Content.getChildren().add(new Label("Toooo"));
                  tab2Content.getChildren().add(new Label("Toooo"));
                  tab2Content.getChildren().add(new Label("Toooo"));
                  tab2Content.getChildren().add(new Label("Toooo"));
                  tab2Content.getChildren().add(new Label("Toooo"));
              });
              //addData(astv, 30);

          }


      }



      REPRODUCIBILITY :
      This bug can be reproduced always.

            aroy Abhijit Roy (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: