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

TreeTableView has trouble with columns specifying pref/min/max widths

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P3
    • Resolution: Fixed
    • 8
    • 8
    • javafx
    • Mac OS X 10.8.3 jdk8b91

    Description

      Run the enclosed program and look at the column headers. Even though the resize policy is CONSTRAINED_RESIZE_POLICY, there is extra space to the right of the last column (B). Resizing the window eventually gets rid of the extra space. However the B column can have a little bit more or less space depending whether you're making the enclosing window bigger or smaller.

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeTableColumn;
      import javafx.scene.control.TreeTableView;
      import javafx.stage.Stage;

      public class TableBug extends Application {
      public static void main(String[] args) {
      Application.launch(args);
      }

      public void start(Stage stage) throws Exception {
      TreeTableColumn<String, String> col1 = new TreeTableColumn<>("Resizable 1");
      col1.setPrefWidth(200);
      col1.setCellValueFactory(cdf -> new SimpleStringProperty(cdf.getValue().getValue()));
      TreeTableColumn<String, String> col2 = new TreeTableColumn<>("Resizable 2");
      col2.setPrefWidth(200);
      col2.setCellValueFactory(cdf -> new SimpleStringProperty(cdf.getValue().getValue()));
      TreeTableColumn<String, String> col3 = new TreeTableColumn<>("A");
      col3.setPrefWidth(30);
      col3.setMaxWidth(30);
      col3.setMinWidth(30);
      col3.setCellValueFactory(cdf -> new SimpleStringProperty("#"));
      TreeTableColumn <String, String> col4 = new TreeTableColumn<>("B");
      col4.setPrefWidth(30);
      col4.setMaxWidth(30);
      col4.setMinWidth(30);
      col4.setCellValueFactory(cdf -> new SimpleStringProperty("%"));
      TreeItem<String> root = new TreeItem<>("Root");
      TreeTableView<String> tv = new TreeTableView<>(root);
      tv.getColumns().addAll(col1, col2, col3, col4);
      tv.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
      tv.setMaxWidth(Double.MAX_VALUE);
      tv.setMaxHeight(Double.MAX_VALUE);
      root.getChildren().add(new TreeItem<>("AAAA"));
      root.getChildren().add(new TreeItem<>("BBBB"));

      Scene scene = new Scene(tv, 800, 600);
      stage.setScene(scene);
      stage.show();
      }
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            cstanford Curtis Stanford
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: