Running a JavaFX 11 interface update at regular intervals (in Kotlin)
up vote
0
down vote
favorite
I want to update a field on a JavaFX 11 UI in response to a thread which retries a process every second and updates statusString
with the result. Since the underlying thread only runs every second, there's no point stinking up the JavaFX Application thread with updates more often than that.
Is this the best way to do it or is there a more elegant way?
fun updateStatus() {
status.text = statusString
val wait = PauseTransition(Duration.seconds(1.0))
wait.setOnFinished { Platform.runLater { updateStatus() } }
}
@FXML
fun initialize() {
thread(start = true) { lookForOpz(); }
Platform.runLater { updateStatus(); }
}
concurrency javafx kotlin
add a comment |
up vote
0
down vote
favorite
I want to update a field on a JavaFX 11 UI in response to a thread which retries a process every second and updates statusString
with the result. Since the underlying thread only runs every second, there's no point stinking up the JavaFX Application thread with updates more often than that.
Is this the best way to do it or is there a more elegant way?
fun updateStatus() {
status.text = statusString
val wait = PauseTransition(Duration.seconds(1.0))
wait.setOnFinished { Platform.runLater { updateStatus() } }
}
@FXML
fun initialize() {
thread(start = true) { lookForOpz(); }
Platform.runLater { updateStatus(); }
}
concurrency javafx kotlin
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to update a field on a JavaFX 11 UI in response to a thread which retries a process every second and updates statusString
with the result. Since the underlying thread only runs every second, there's no point stinking up the JavaFX Application thread with updates more often than that.
Is this the best way to do it or is there a more elegant way?
fun updateStatus() {
status.text = statusString
val wait = PauseTransition(Duration.seconds(1.0))
wait.setOnFinished { Platform.runLater { updateStatus() } }
}
@FXML
fun initialize() {
thread(start = true) { lookForOpz(); }
Platform.runLater { updateStatus(); }
}
concurrency javafx kotlin
I want to update a field on a JavaFX 11 UI in response to a thread which retries a process every second and updates statusString
with the result. Since the underlying thread only runs every second, there's no point stinking up the JavaFX Application thread with updates more often than that.
Is this the best way to do it or is there a more elegant way?
fun updateStatus() {
status.text = statusString
val wait = PauseTransition(Duration.seconds(1.0))
wait.setOnFinished { Platform.runLater { updateStatus() } }
}
@FXML
fun initialize() {
thread(start = true) { lookForOpz(); }
Platform.runLater { updateStatus(); }
}
concurrency javafx kotlin
concurrency javafx kotlin
asked yesterday
Mark Green
29217
29217
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207611%2frunning-a-javafx-11-interface-update-at-regular-intervals-in-kotlin%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password