How can I change a JavaFX UI but not triggered by user gesture such as a button clicked, but triggered by an outside function (some data received) that calls a function that updates the UI?
I saw in a few questions here that task should resolve this issue, but I did not understand the below example completely: I want to link (observer pattern) a kinesis consumer to fill color of a circle in my GUI. I get that I need to bind the fill property of that circle to consumed record event, but I did not understand what is: task.progressProperty()? in the example code. And to what I change it to, to get a link a record consumed to a circle fill?
Thanks!
import javafx.concurrent.Task;
Task task = new Task<Void>() {
@Override public Void call() {
static final int max = 1000000;
for (int i=1; i<=max; i++) {
if (isCancelled()) {
break;
}
updateProgress(i, max);
}
return null;
}
};
ProgressBar bar = new ProgressBar();
bar.progressProperty().bind(task.progressProperty());
new Thread(task).start();