I use a JavaFX task to go through some initialisation process. The progress of that process shall be displayed on my GUI. Therefore I usesd a Task instead of "Platform.runLater". "Platform.runLater" does not update at runtime. At several points at the init process I need some interaction with the user. So I call a JavaFX "Alert" dialog. But the call to "new Alert(...);" do never return! If I use "Platform.runLater" the dialog appears but theres is no GUI update while the init process.
I'm trapped...
private static void mainInit() {
// do some init stuff here...(and show it to the user)
Alert alert = new Alert(AlertType.INFORMATION);
// program never reaches this line...
alert.setTitle("Hallo");
}
public void start(Stage primaryStage) {
Task<Void> initTask = new Task<Void>() {
@Override
protected Void call() throws Exception {
mainInit();
return null;
}
};
new Thread(initTask).start();
}