Reputation: 29
I am creating a JavaFX application that loads multiple images from the internet (about 50)
The problem is that when I load all the images (with a thread), it displays them all at once which slows down the process.
I would like to display the images one by one when they have finished loading instead of displaying all at once (like YouTube).
I have been looking for a solution to this question for several days but I have not found anything...
Thank you in advance 😃
Upvotes: 1
Views: 252
Reputation: 159606
Load the image in the background, by setting the backgroundLoading
parameter to true
:
ImageView view = new ImageView(
new Image(url, true)
);
The ImageView will automatically display the image when it has completed loading.
From the Image javadoc:
// load an image in background, displaying a placeholder while it's loading // (assuming there's an ImageView node somewhere displaying this image) // The image is located in default package of the classpath Image image1 = new Image("/flower.png", true);
Upvotes: 3