title: How to wait for a result with multiple JavaFX Windows in a static function?
body: <p>My question is, how I can easily wait on the result of a window in witch the user is entering some informations?</p>
  
  <p>Basic Problem:</p>
  
  <pre><code>public static char[] getPassword(String message) {
          run = true;
          showWindow(message);   // JFrame or FX-Window
  
          /* DOES NOT WAIT HERE !!! */
  
          // Working on the insert data of "password1"
          if (pwMatches()) {
              return password1;
          } else {
              return null;
          }
      }
  </code></pre>
  
  <p><a href="https://pastebin.com/06itDs1X" rel="nofollow noreferrer">https://pastebin.com/06itDs1X</a> - only pseudo code, untested! Real code is to complex.</p>
  
  <p>The task:</p>
  
  <ul>
  <li>FX-Window is running (main stage)</li>
  <li>User should enter a new password in a stage (pw stage)</li>
  <li>after entering the password, the main stage should go on</li>
  </ul>
  
  <p>The Problem:</p>
  
  <ul>
  <li>main stage does not wait, goes on before password is entered</li>
  <li>simple demo code: <a href="https://pastebin.com/560v1wmd" rel="nofollow noreferrer">https://pastebin.com/560v1wmd</a></li>
  </ul>
  
  <p>results</p>
  
  <pre><code>main 1
  main 2
  s1
  s2
  </code></pre>
  
  <p>The solutions:</p>
  
  <ul>
  <li>1:  https:// pastebin.com/kCAep2gr</li>
  <li>2:  https:// pastebin.com/MSJ0kHfU</li>
  </ul>
  
  <p>results the correct order</p>
  
  <pre><code>main 1
  s1
  s2
  main 2
  </code></pre>
  
  <p>Problem:</p>
  
  <ul>
  <li><p>Solution 1 needs much modifications in the code.</p>
  
  <ul>
  <li>I used this, but would ask for a better solution or is this the best?</li>
  </ul></li>
  <li><p>Solution 2 does not work for JavaFX (Thread is no FX-Thread)</p></li>
  </ul>
  
  <h1>Question:</h1>
  
  <p>Any easy solution for JavaFX or is Solution 1 the best?</p>