I have a pretty simple game that I'm making (with a pretty basic gui) and it uses JavaFx buttons to choose what will happen. Each button has a message and an ActionEvent tied to it. When I run the method though the program doesn't stop to wait for user input but rather just goes right into the next gui screen. Each prompt method changes the Scene of the program so in this example it skips right over story1() and goes straight to story2(). My program is a bit more complex than this but it gets the gist of what is going on.
public void prompt(String msg1, ActionEvent event1, String msg2, ActionEvent event2){
....
window.setScene(<scene with buttons and text>)
}
public void story1(){
prompt("say yes", event ->{do stuff}, "say no", event -> {Don't do stuff};
**WAIT FOR A USER TO CLICK A BUTTON THEN MOVE TO story2**
}
public void story2(){
prompt(...)
**WAIT FOR USER INPUT DO NOT GO AHEAD UNTIL A BUTTON IS PRESSED**
}
public static void main(String[] args){
story1(); //Don' proceed until buttons are pressed
story2();
}
I have tried using Thread.wait() and while loops and tried to understand ActionListener and Runnable but I couldn't figure it out so I decided to post here.