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

ListView/TableView in VBox breaks layout.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • javafx
    • None

    Description

      Affects JavaFX 8.0 b84

      Appearently, if you put a ListView/TableView inside a VBox, it behaves very strange.

      It has something to do with the VBox's minHeight/prefHeight/maxHeight.

      The height calculation of the ListView seems to be wrong. Change the height values to see the effect.


      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.geometry.Insets;
      import javafx.geometry.Orientation;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.scene.layout.VBoxBuilder;
      import javafx.stage.Stage;

      public class TestApp5 extends Application {

          public static void main(String[] args) {
              try {
                  launch(args);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }

          public void start(final Stage stage) throws Exception {

              SplitPane splitPane = new SplitPane();
              splitPane.setOrientation(Orientation.VERTICAL);

              ListView<String> listView = new ListView<String>();

              ObservableList<String> items = FXCollections.observableArrayList();
              listView.setItems(items);

              for (int i = 0; i < 30; i++) {
                  items.add(Integer.toString(i));
              }


              VBox root = new VBox();

              VBox vBox = VBoxBuilder.create().children(listView).build();
              splitPane.getItems().add(vBox);

              Button button = new Button();
              button.setPrefHeight(100);
              splitPane.getItems().add(button);

              // Change these values.
              //vBox.setMinHeight(0);
              vBox.setPrefHeight(100);
              vBox.setMaxHeight(100);
              //

              root.getChildren().add(splitPane);

              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
          }
      }

      Attachments

        Issue Links

          Activity

            People

              jgiles Jonathan Giles
              cschudtjfx Christian Schudt (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: