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

TabPane dont update Size

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u92
    • javafx
    • x86
    • windows_8

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1

      A DESCRIPTION OF THE PROBLEM :
      if the content in an Tab / TabPane changes its size
      the TabPane don’t update its size:

      * increase width / height
      -> TabPane only updates layout after switch to other tab
      * decrease width / height
      -> TabPane holds its current size


      REGRESSION. Last worked in version 8u92

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      start test case
      change width / height to 200
      change width / height to 20

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      change width / height to 200
      change width / height to 20
      -> TabPane update its size


      ACTUAL -
      change width / height to 200
      change width / height to 20
      -> TabPane holds current size

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.beans.property.DoubleProperty;
      import javafx.geometry.Pos;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.scene.text.TextAlignment;
      import javafx.stage.Stage;

      public class TabPaneSizeMain extends Application
      {
          private static final double USE_PREF_SIZE = Double.NEGATIVE_INFINITY;
          private static final double USE_COMPUTED_SIZE = -1.0;
          
          public static void main(String[] args) {
              launch(TabPaneSizeMain.class, args);
          }
          
          @Override
          public void start(Stage primaryStage) throws Exception {
              
              final TabPane tabPane = new TabPane();
              tabPane.setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
              tabPane.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
              tabPane.setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
              
              final Label content = new Label("content");
              content.setTextAlignment(TextAlignment.CENTER);
              content.setStyle("-fx-background-color: green;");
              
              // content
              tabPane.getTabs().add(new Tab("content", content));
              // switch Tabs -> TabPane doLayout
              tabPane.getTabs().add(new Tab("doLayout()"));
              
              // Input to set Label - size
              final Node width = textField("width", content.minWidthProperty(), content.prefWidthProperty(), content.maxWidthProperty());
              final Node height = textField("height", content.minHeightProperty(), content.prefHeightProperty(), content.maxHeightProperty());
              
              final BorderPane root = new BorderPane();
              BorderPane.setAlignment(tabPane, Pos.TOP_LEFT);
              root.setCenter(tabPane);
              
              root.setTop(new HBox(10, width, height));
              
              primaryStage.setScene(new Scene(root, 640, 480));
              primaryStage.sizeToScene();
              primaryStage.centerOnScreen();
              primaryStage.show();
          }

          private Node textField(final String name, final DoubleProperty ...properties)
          {
              final Label label = new Label(name);
              final TextField input = new TextField();
              input.textProperty().addListener((ov, from, to) -> {
                  try
                  {
                      final double size = Double.parseDouble(to);
                      for(final DoubleProperty property : properties)
                      {
                          property.unbind();
                          property.set(size);
                      }
                  }
                  catch(final Throwable ignore)
                  {
                      //
                  }
              });
              
              return new HBox(5, label, input);
          }
      }
      ---------- END SOURCE ----------

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: