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

TableView Columns growing behaviour

XMLWordPrintable

      With this sample code based on empty ObservableList, the columns not growing. With two row-items, the columns are growing but threre is a third empty, useless "column" in the table visible.

      public void start(Stage primaryStage) throws Exception {
              Group rootGroup = new Group();
              Scene scene = new Scene(rootGroup, 800, 600);
       
              primaryStage.setScene(scene);
       
              ObservableList<Dimension> testItems = FXCollections.observableArrayList();
              //testItems.add(new Dimension(100, 200));
              //testItems.add(new Dimension(300, 400));
       
              TableView<Dimension> table = new TableView<Dimension>();
              table.setItems(testItems);
       
              TableColumn<String> testColumn = new TableColumn<String>("Width");
              testColumn.setResizable(true);
              testColumn.setProperty("width");
              testColumn.setMinWidth(100);
       
              TableColumn<String> testColumn2 = new TableColumn<String>("Height");
              testColumn2.setResizable(true);
              testColumn2.setProperty("height");
              testColumn2.setMinWidth(100);
       
              table.getColumns().addAll(testColumn, testColumn2);
              table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
       
              BorderPane mainPane = new BorderPane();
              mainPane.setCenter(table);
       
              scene.setRoot(mainPane);
       
              primaryStage.centerOnScreen();
              primaryStage.setVisible(true);
          }

        1. Main.java
          4 kB
        2. screenshot-1.jpg
          screenshot-1.jpg
          23 kB
        3. screenshot-2.jpg
          screenshot-2.jpg
          13 kB

            jgiles Jonathan Giles
            ageistjfx Alexander Geist (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: