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

[TreeTableView] items are misaligned after being grouped, but only when using CONSTRAINED_RESIZE_POLICY

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      Win 8.1 64bit, JDK 8u40-b10 64bit.

      Description

      I've tested this up to 8u40-b10. When there's a TreeTableView using TreeTableView.CONSTRAINED_RESIZE_POLICY it's possible to get items misaligned by moving them around in the tree. I'll post an example below.

      Steps to reproduce:

      1) Run the example.

      The item labelled "two" should be indented to the right of item "one", but it's aligned all the way to the left of the table. Note this only happens when using CONSTRAINED_RESIZE_POLICY.

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

      public class TreeTableAlignmentIncorrectAfterItemGrouping extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {
              TreeTableView<Person> treeTable = new TreeTableView<>();
              treeTable.setShowRoot(false);
              treeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);

              TreeTableColumn<Person, String> column = new TreeTableColumn<>("Name");
              column.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
              treeTable.getColumns().add(column);

              TreeItem<Person> root = new TreeItem<>();
              treeTable.setRoot(root);

              TreeItem<Person> one = new TreeItem<>(new Person("one"));
              root.getChildren().add(one);

              TreeItem<Person> two = new TreeItem<>(new Person("two"));
              root.getChildren().add(two);

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

              // Select two, then move two from root to one.
              treeTable.getSelectionModel().select(two);
              root.getChildren().remove(two);
              one.getChildren().add(two);
              one.setExpanded(true);
          }

          public static void main(String[] args) {
              launch();
          }

          public class Person {
              private final StringProperty name = new SimpleStringProperty();
              public final ReadOnlyStringProperty nameProperty() {return name;}
              public final String getName() {return name.get();}
              public final void setName(String name) {this.name.set(name);}

              public Person(String name) {
                  setName(name);
              }
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jgiles Jonathan Giles
              Reporter:
              rjaebjfx Ryan Jaeb (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: