I am writing a simple code that displays the content of a table with javaFX. I would like the program to pause every time a new content is displayed.
for(int i = 0; i < table.size(); i++){
label.setText(table[i]);
Thread.sleep(2000); // The program stops for 2 seconds
}
The problem is, Thread.sleep()
doesn't work as planed. In fact, the program pauses before even displaying the content.
How can I correct this issue ?