I'm doing some kind of social, it's when i open a post a new scene is created which initializes the elements with the data taken from the database. the problem is that the big photos take time to load, and until they load the program does not respond, I would like a way to be able to open the scene first so as to wait until the image loads without the program crashing
public void init(int idpost) throws SQLException {
this.post = new PostDAOImpl().getPost(idpost);
photo.fitWidthProperty().bind(imgContainer.widthProperty());
photo.fitHeightProperty().bind(imgContainer.heightProperty());
photo.setImage(new Image(post.getPhoto()));
name.setText(post.getProfile().getName());
username.setText("@" + post.getProfile().getUsername());
if (post.getProfile().getAvatar() != null)
avatar.setImage(new Image(post.getProfile().getAvatar()));
description.setText(post.getDescription());
}
here is the code, which is executed as soon as the scene loads. I was thinking of doing another DAO to first fetch all the data except the photo, load the scene and only then fetch the image or something like that, but I don't know how to do it