Add this to HelloTableView.Java:
tableView.setOnMouseReleased(new EventHandler<MouseEvent>() {
public void handle(MouseEvent t) {
if (t.getClickCount() == 3) {
System.out.println("resetting data...");
long t0 = System.currentTimeMillis();
ObservableList<List<Double>> empty = FXCollections.observableArrayList();
tableView.setItems(empty);
bigData.clear();
getLines(bigData);
tableView.setItems(bigData);
long t1 = System.currentTimeMillis();
System.out.println("Done: " + (t1 - t0));
}
}
});
The code attempts to set empty items into the table then set new items to avoid the code of updating each item in place (whether there is a cost here or not is not the issue).
0) Run HelloTableView
1) Click on 'Performance Test'
2) Triple click on a table item
3) Triple click on a table item again
4) Triple click on a table item once more
5) Setting the table contents gets slower each time
Here is the output:
resetting data...
Done: 12
resetting data...
Done: 2682
resetting data...
Done: 5211
tableView.setOnMouseReleased(new EventHandler<MouseEvent>() {
public void handle(MouseEvent t) {
if (t.getClickCount() == 3) {
System.out.println("resetting data...");
long t0 = System.currentTimeMillis();
ObservableList<List<Double>> empty = FXCollections.observableArrayList();
tableView.setItems(empty);
bigData.clear();
getLines(bigData);
tableView.setItems(bigData);
long t1 = System.currentTimeMillis();
System.out.println("Done: " + (t1 - t0));
}
}
});
The code attempts to set empty items into the table then set new items to avoid the code of updating each item in place (whether there is a cost here or not is not the issue).
0) Run HelloTableView
1) Click on 'Performance Test'
2) Triple click on a table item
3) Triple click on a table item again
4) Triple click on a table item once more
5) Setting the table contents gets slower each time
Here is the output:
resetting data...
Done: 12
resetting data...
Done: 2682
resetting data...
Done: 5211