Why am I getting java.lang.IllegalStateException "Not on FX application thread" on JavaFX?
The user interface cannot be directly updated from a non-application thread. Instead, use Platform.runLater()
, with the logic inside the Runnable object. For example:
Platform.runLater(new Runnable() {
@Override
public void run() {
// Update UI here.
}
});
As a lambda expression:
// Avoid throwing IllegalStateException by running from a non-JavaFX thread.
Platform.runLater(
() -> {
// Update UI here.
}
);
JavaFX code allows updating the UI from an JavaFX application thread. But from the above exception message it says that it is not using FX Application thread.
One way you can fix is to launch an FX Application thread from the resetPage method and do the modifications there.