I'm making a step-by-step based game with JavaFX and I'm using do while loop to wait for user input. The problem is, it's called from a fxml controller initialize method and that means the interface will never load. The solution is to wait using another thread, but JavaFX doesn't allow to modify any nodes from secondary threads.

I avoided getting the "Not on FX application thread" by using this code:

```
public void initialize(URL arg0, ResourceBundle arg1) {
        // I call the game engine to start the game sequence and I pass root into it for further use
        engine = new GameEngine(root);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                engine.start();
            }
          });
    }

```

inside engine.start() method:

```
public void start() {
        System.out.println("Game started");
        text("Hello, stranger"); // a new Label inside VBox
        do {
            try {
                Thread.sleep((long) 1000);
                System.out.println("Sleeping...");
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.out.println("Error... waiting?");
            }
        } while(this.listener == false); // Listener triggers when user inputs.

        System.out.println("ENTER PRESSED, May proceed");
        text("It worked!");
    }

```

Also, GameEngine extends Thread, and I don't know how it affects anything beside multithreading.

When the code is launched, UI crashed and output gives Sleeping... every second like it should.