I have an application that is to launch a die, when you press the button to launch it, a random number is created 6 times (using a Thread.sleep ()) and must therefore display the face dice corresponding to the number, but here it shows me only the last digit, the others before do not appear. Here is my code:
private List listeFaceDice;
for(i=0;i<6;i++) {
setRandomNum(rand.nextInt((6 - 1) + 1) + 1);
imageView.setImage(listeFaceDice.get(randomNum-1));
Thread.sleep(1000);
}
with a TimeLine :
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0.5), event -> {
setRandomNum(rand.nextInt((6 - 1) + 1) + 1);
imageView.setImage(listeFaceDice.get(randomNum-1));
//System.out.println(getRandomNum());
}));
timeline.setCycleCount(6);
timeline.play();
timeline.setOnFinished(e -> {
setRandomNum(randomNum);
});
It works with the time LimeLine but I don't know how to get the value at the end of the animation, because I called this method when I press a button. Thank in advance ;)