Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8289481 | jfx17.0.4 | Johan Vos | P3 | Resolved | Fixed |
FULL PRODUCT VERSION :
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux asus14 4.4.0-103-generic #126-Ubuntu SMP Mon Dec 4 16:23:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Removing one TreeItem from a TreeTableView changes TreeTableView selectedItem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the following javafx program:
----------------------------------------------------
package sample;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
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 Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
TreeItem<String> rootNode = new TreeItem<String>("Root");
rootNode.setExpanded(true);
for (int i = 0; i < 3; i++) {
rootNode.getChildren().add(new TreeItem<>("Node " + i));
}
for (int i = 0; i < 2; i++) {
TreeItem<String> node = rootNode.getChildren().get(i);
node.setExpanded(true);
for (int j = 0; j < 2; j++) {
node.getChildren().add(new TreeItem<>("Sub Node " + i + "-" + j));
}
}
TreeTableColumn<String, String> column = new TreeTableColumn<>("Nodes");
column.setCellValueFactory((TreeTableColumn.CellDataFeatures<String, String> p) -> {
return new ReadOnlyStringWrapper(p.getValue().getValue());
});
column.setPrefWidth(200);
TreeTableView<String> table = new TreeTableView<>(rootNode);
table.getColumns().add(column);
int selectIndex = 4; // select "Node 1"
int removeIndex = 2; // remove "Node 2"
table.getSelectionModel().select(selectIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
table.getRoot().getChildren().remove(removeIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
primaryStage.setTitle("Tree Table View Selection");
primaryStage.setScene(new Scene(table, 300, 275));
primaryStage.show();
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selected index = 4
Selected item = Node 1
Selected index = 4
Selected item = Node 1
ACTUAL -
Selected index = 4
Selected item = Node 1
Selected index = 3
Selected item = Sub Node 0-1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sample;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
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 Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
TreeItem<String> rootNode = new TreeItem<String>("Root");
rootNode.setExpanded(true);
for (int i = 0; i < 3; i++) {
rootNode.getChildren().add(new TreeItem<>("Node " + i));
}
for (int i = 0; i < 2; i++) {
TreeItem<String> node = rootNode.getChildren().get(i);
node.setExpanded(true);
for (int j = 0; j < 2; j++) {
node.getChildren().add(new TreeItem<>("Sub Node " + i + "-" + j));
}
}
TreeTableColumn<String, String> column = new TreeTableColumn<>("Nodes");
column.setCellValueFactory((TreeTableColumn.CellDataFeatures<String, String> p) -> {
return new ReadOnlyStringWrapper(p.getValue().getValue());
});
column.setPrefWidth(200);
TreeTableView<String> table = new TreeTableView<>(rootNode);
table.getColumns().add(column);
int selectIndex = 4; // select "Node 1"
int removeIndex = 2; // remove "Node 2"
table.getSelectionModel().select(selectIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
table.getRoot().getChildren().remove(removeIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
primaryStage.setTitle("Tree Table View Selection");
primaryStage.setScene(new Scene(table, 300, 275));
primaryStage.show();
}
---------- END SOURCE ----------
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux asus14 4.4.0-103-generic #126-Ubuntu SMP Mon Dec 4 16:23:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Removing one TreeItem from a TreeTableView changes TreeTableView selectedItem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the following javafx program:
----------------------------------------------------
package sample;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
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 Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
TreeItem<String> rootNode = new TreeItem<String>("Root");
rootNode.setExpanded(true);
for (int i = 0; i < 3; i++) {
rootNode.getChildren().add(new TreeItem<>("Node " + i));
}
for (int i = 0; i < 2; i++) {
TreeItem<String> node = rootNode.getChildren().get(i);
node.setExpanded(true);
for (int j = 0; j < 2; j++) {
node.getChildren().add(new TreeItem<>("Sub Node " + i + "-" + j));
}
}
TreeTableColumn<String, String> column = new TreeTableColumn<>("Nodes");
column.setCellValueFactory((TreeTableColumn.CellDataFeatures<String, String> p) -> {
return new ReadOnlyStringWrapper(p.getValue().getValue());
});
column.setPrefWidth(200);
TreeTableView<String> table = new TreeTableView<>(rootNode);
table.getColumns().add(column);
int selectIndex = 4; // select "Node 1"
int removeIndex = 2; // remove "Node 2"
table.getSelectionModel().select(selectIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
table.getRoot().getChildren().remove(removeIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
primaryStage.setTitle("Tree Table View Selection");
primaryStage.setScene(new Scene(table, 300, 275));
primaryStage.show();
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selected index = 4
Selected item = Node 1
Selected index = 4
Selected item = Node 1
ACTUAL -
Selected index = 4
Selected item = Node 1
Selected index = 3
Selected item = Sub Node 0-1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sample;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
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 Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
TreeItem<String> rootNode = new TreeItem<String>("Root");
rootNode.setExpanded(true);
for (int i = 0; i < 3; i++) {
rootNode.getChildren().add(new TreeItem<>("Node " + i));
}
for (int i = 0; i < 2; i++) {
TreeItem<String> node = rootNode.getChildren().get(i);
node.setExpanded(true);
for (int j = 0; j < 2; j++) {
node.getChildren().add(new TreeItem<>("Sub Node " + i + "-" + j));
}
}
TreeTableColumn<String, String> column = new TreeTableColumn<>("Nodes");
column.setCellValueFactory((TreeTableColumn.CellDataFeatures<String, String> p) -> {
return new ReadOnlyStringWrapper(p.getValue().getValue());
});
column.setPrefWidth(200);
TreeTableView<String> table = new TreeTableView<>(rootNode);
table.getColumns().add(column);
int selectIndex = 4; // select "Node 1"
int removeIndex = 2; // remove "Node 2"
table.getSelectionModel().select(selectIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
table.getRoot().getChildren().remove(removeIndex);
System.out.println("Selected index = " + table.getSelectionModel().getSelectedIndex());
System.out.println("Selected item = " + table.getSelectionModel().getSelectedItem().getValue());
primaryStage.setTitle("Tree Table View Selection");
primaryStage.setScene(new Scene(table, 300, 275));
primaryStage.show();
}
---------- END SOURCE ----------
- backported by
-
JDK-8289481 Removing TreeItem from a TreeTableView sometime changes selectedItem
- Resolved
- relates to
-
JDK-8248217 ☂ TreeTableView selection issues
- Open
- links to
-
Commit openjdk/jfx17u/97a3f7fe
-
Commit openjdk/jfx/3bb2db12
-
Review openjdk/jfx17u/68
-
Review openjdk/jfx/753
(1 links to)