I am trying to populate my TreeView with several thousand items but when I go to open the new scene with the TreeView it takes around 3-6 minutes for it to finish populating and opening the new scene.
Here's the code im currently using.
Platform.runLater(() -> {
//populates indices with archives
try {
for (int index = 0; index < ...; index++) {
if(... > 0) {
int archives = ...;
for (int archive = 0; archive < archives; archive++) {
CacheTreeItem treeNode = new CacheTreeItem("folder " + archive);
rootNode.getChildren().get(finalMainFile).getChildren().get(index).getChildren().add(treeNode);
if(table != null && table.getEntry(archive) != null)
for(int child = 0; child < table.getEntry(archive).capacity(); child++) {
CacheTreeItem treeNode2 = new CacheTreeItem("file " + child);
rootNode.getChildren().get(finalMainFile).getChildren().get(index).getChildren().get(archive).getChildren().add(treeNode2);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
});
Indices are around 40 files. Some archives are in the thousands and some of the children are in the hundreds. Is there a way to make this faster?