-
Bug
-
Resolution: Fixed
-
P4
-
8u20
-
Win 8.1 64bit, JDK 8u40-b10 64bit.
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);
}
}
}
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);
}
}
}
- relates to
-
JDK-8094456 TreeTableView doesn't maintain position properly when cells count changes
- Resolved