So when I launch my application I show a button over my window as a loading screen/click to play button. So when the application starts, it says "Loading" and is set to disabled in the initalize method. Then my controller instantiates another class that uses 4 threads to compute a thing, this is supposed to last during the time the user sees the loading screen. So my Controller instantiates a private class which acts as a callback to the class with multiple threads. When that class is done computing, it will callback to the controller that it is finished. When this happends I want to Enable my button again and change the text so the user can click it and begin. This is part of the code:
@FXML
private Button btnStart;
private final MuliThreadedClass treeBuilderStarter = new TreeBuilderStarter(board, new CBTreeDoneImpl());
private class CBTreeDoneImpl implements CBThreadDone{
@Override
public void done(ComplextObject obj) {
btnStart.setDisable(false);
btnStart.setText("Click to start!");
}
}
@FXML
public void initialize() {
btnStart.setDisable(true);
}
Now when the callback is called and
btnStart.setDisable(false);
btnStart.setText("Click to start!");
is executed I get an exception saying IllegalStateException not on FX thread. I understand the issue, but how would you go about fixing this?