How to open an additional window in a JavaFX FXML app?
<p>In my JavaFX FXML app, I want a secondary window to pop up when the user clicks a menu item somewhere in the primary window so that the user can enter some input into it, which will be then fed to the application upon clicking a button, and the secondary window will be closed.</p>

<p>All the tutorials out there are slightly off the mark. They describe how to do it in pure JavaFX, which is apparently different from the way you'd use with FXML, or they explain how to switch Scenes, which closes the old Scene. I'd guess it would be simple enough, along the lines of defining the FXML layout and its Controller, creating a new Scene with them, and then calling something like</p>

<pre><code>theStage.showScene(userInputWindow);
</code></pre>

<p>but a working solution seems much more complicated, and the reasoning behind it different from my assumptions. For example in <a href="http://www.javafxtutorials.com/tutorials/switching-to-different-screens-in-javafx-and-fxml/" rel="nofollow">this tutorial</a>, I don't really understand why did they put that cast in there, what would the FXMLLoader() actually do, or indeed how would I adapt any of this to the task at hand. Also, the resource states the "the stage can only show 1 scene at a time". It seems extremely unlikely to me that a JavaFX app could lack such a trivial feature as showing a new window without closing the old one. Maybe I misunderstood something about what a Stage and a Scene are and what they can do. So I need to know:</p>

<ol>
<li><p>How to achieve the effect described above in code?</p></li>
<li><p>What is the reasoning behind the solution; what do all the things involved do there?</p></li>
</ol>