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

TabPane cannot shrink

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u20
    • javafx
    • Windows 7

      A TabPane preferred size can only grow, it shall be able to reduce when the content change.
      Changing maxw and maxh to local variables in TabPaneSkin would solve the issue.

      Sample code:

      public class TabPaneSample extends Application{
      Button growButton = new Button("Grow");
      VBox vbox = new VBox(growButton);
      Tab tab = new Tab("tab");
      TabPane tabPane = new TabPane();

      @Override
      public void start(Stage primaryStage) throws Exception {
      // Create Scene
      // Stage -> TabPane -> Tab -> VBox -> Button
      vbox.setPrefWidth(200);
      tabPane.getTabs().add(tab);
      tab.setContent(vbox);
      primaryStage.setScene(new Scene(tabPane));

      // Button's action
      // growButton add a button that remove itself
      growButton.setOnAction(e -> {
      Button shrinkButton = new Button("Shrink");
      shrinkButton.setOnAction(event -> {
      vbox.getChildren().remove(shrinkButton);
      tabPane.requestLayout();
      primaryStage.sizeToScene();
      });
      vbox.getChildren().add(shrinkButton);
      tabPane.requestLayout();
      primaryStage.sizeToScene();
      });

      primaryStage.show();
      }

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

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: