Using JavaFX, with the click of a button I want to do this:
spinBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
field.setDisable(false);
field.setDisable(true);
}
});
I quickly realized that sleep would not work, as it completely freezes the GUI. I also tried sleeping threads to get a timer, but which still depends on the GUI if the input signal is where I want a delay. (Example below)
spinBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ExampleTimerThread exampleSleepyThread = new ExampleTimerThread();
exampleSleepyThread.start();
while(finished == true){
field.setDisable(false);
}
}
});
What can I do to prevent this code from freezing the GUI? I know in Swing, there is a timer. Is there something similar in JavaFX?
source
share