You should never wait for a stream of FX applications; it will freeze the user interface and make it unresponsive, both in terms of processing user actions and in terms of displaying something on the screen.
If you want to update the user interface at the end of a lengthy process, use the javafx.concurrent.TaskAPI . For example.
someButton.setOnAction( event -> {
Task<SomeKindOfResult> task = new Task<SomeKindOfResult>() {
@Override
public SomeKindOfResult call() {
SomeKindOfResult result = ... ;
return result ;
}
};
task.setOnSucceeded(e -> {
SomeKindOfResult result = task.getValue();
});
new Thread(task).start();
});
Obviously replace SomeKindOfResultwith what type of data represents the result of your long process.
Please note that the code in the block onSucceeded:
- must be performed after task completion
- has access to the result of the background task through
task.getValue() - essentially it is in the same volume as the place where you started the task, so it has access to all elements of the user interface, etc.
, , , " ", .