title: How can I get make my program wait until JavaFX window has been closed before continuing?
body: <p>I have a program that is displaying a barchart of results. I want to wait until the user closes the bar chart to continue to the next line of code which is asking if they want to enter new information for the chart.</p>
  
  <pre><code>Scene scene = BarGraph.getBarChart();
  primaryStage.setScene(scene);
  primaryStage.setTitle("Bar Chart");
  primaryStage.show();
  
  repeat = JOptionPane.showConfirmDialog(null, "Would you like to enter another number?");
  </code></pre>
  
  <p>What is happening is the scene for the bar chart will open, but nothing will be displayed and immediately JOptionPane pops up with the question. If I hit no, then the chart displays, but the program ends. If I hit yes, the program loops back to earlier dialog windows, but won't display the chart until the other dialog ends.</p>
  
  <p>I want to wait to prompt the user until after they close the bar chart. I'm so frustrated at this point, that I'd even put an artificial pause like wait(5000) or something, though I have not been able to get that to work either.</p>
  
  <p>I've read into this so much and have yet to find a solution that actually works. The closest question was this: <a href="https://stackoverflow.com/questions/34255083/javafx-wait-till-stage-has-been-closed">JavaFX wait till stage has been closed</a></p>
  
  <p>From what I read there is that I can't actually cause the program to wait, but can set actions to occur once the window is closed. But following the suggestions there just caused the stage to open and then immediately close. I've been down several other rabbit holes, but to no avail.</p>