Reputation: 151
Is it possible to do a lazy loading for images in JavaFx? It has a hundreds of picture and it took time to load the images. I would like to implement lazy loading so when I am scrolling on the stackpane, the images will also load.
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
Image img = new Image(listOfFiles[i].toURI().toString());
}
Upvotes: 3
Views: 480
Reputation: 506
You can use background loading see in the documentation. With the flag true
Image myImage= new Image("/icons/test.png",true);
Upvotes: 1