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

[Layout] ListCell and FlowPane, minHeight issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u20
    • 8
    • javafx
    • Windows 8.1 64bit

    Description

      FlowPane in horizontal mode uses the same value for prefHeight and minHeight.
      I do not understand how can a FlowPane be rendered smaller than its minHeight (but enough to display its content) inside a VBox, while it can not inside a ListCell.

      The following code shows that a FlowPane inside a VBox will be rendered and resized appropriately. However, inside a ListCell, the ListCell will always resize using the FlowPane's minHeight, causing an ugly experience!

      FlowPane flowPane = new FlowPane();
      flowPane.setPrefWidth(50);
      flowPane.setPrefWrapLength(50);
      flowPane.setVgap(5);
      flowPane.setHgap(5);
      flowPane.setMaxWidth(Double.MAX_VALUE);
      Button button = new Button("Click Me!");
      button.setOnAction(evt -> {
          flowPane.getChildren().add(new Button("Button"));
      });
      flowPane.getChildren().add(button);


      VBox vBox = new VBox(new Label("I am (and will stay) right after the FlowPane"));
      ListView<FlowPane> listView = new ListView<>();

      Tab tab1 = new Tab("ListCell");
      tab1.setContent(listView);
      tab1.selectedProperty().addListener((observable, oldValue, newValue) -> {
          if (newValue) {
              vBox.getChildren().remove(flowPane);
              listView.getItems().add(flowPane);
          }
      });
      Tab tab2 = new Tab("VBox");
      tab2.setContent(vBox);
      tab2.selectedProperty().addListener((observable, oldValue, newValue) -> {
          if (newValue) {
              listView.getItems().remove(flowPane);
              vBox.getChildren().add(0, flowPane);
          }
      });
      TabPane tabPane = new TabPane();
      tabPane.getTabs().addAll(tab1,tab2);

      primaryStage.setScene(new Scene(tabPane));
      primaryStage.show();

      Attachments

        Issue Links

          Activity

            People

              msladecek Martin Sládeček
              asulaimanjfx Anas H. Sulaiman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: