title: JavaFx Stuck in while loop
body: <p>I am new to JavaFx and am trying to code my hangman game. I am at the point where I have to check to see if the file that holds my lexicon is there. If not ask user to enter its location. I am trying to do this in a popup windows that asks the user to enter the location and hit a button, This button in turn will cause the textbox.getText() to be saved and loaded in. If it is a bad location, repeat. I have purposely misspelled the location to get this popup to run, but it is stuck in a while loop and forced me to end app. I am running it as a new Scene, but am stuck on what to do next. Here is my Controller.java</p>
  
  <p>FYI: though this is a homework assignment from a university, I am not enrolled. I am on disability and my friend is going through the class. I am trying to stay busy by playing with his assignments. Love to code and this keeps me busy, up-to-date, and I get to learn new things.</p>
  
  <pre><code>package sample;
  import javafx.geometry.Insets;
  import javafx.geometry.Pos;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.VBox;
  import javafx.stage.Modality;
  import javafx.stage.Stage;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  
  
  public class Controller {
  
      public Label welcomeLabel, guessesLettersLabel, GuessesRemainingLabel, currentStateLAbel, endGameMessageLabel;
      public Button newGameButton, exitButton, enterTextButton;
      public TextField enterTextBox;
      public boolean ynAnswer;
      public String textAnswer;
      Stage window;
      File inputFile;
  
  
      public void newGame() throws FileNotFoundException {
  
          Scanner input = new Scanner(System.in);
  
          inputFile = new File("src\\sample\\HangmanLexcon.txt");
          while(!inputFile.exists()) {
              window = new Stage();
              window.initModality(Modality.APPLICATION_MODAL);
              window.setTitle("File was not found.");
              window.setMinWidth(250);
              window.setMaxHeight(100);
  
              //form
              TextField fileInput = new TextField();
              Button inputButton = new Button("Upload File");
              inputButton.setOnAction(e -&gt; {
                  inputFile = new File(fileInput.getText());
                  window.close();
              });
  
  
              //Layout
              VBox layout = new VBox(10);
              layout.setPadding(new Insets(20, 20, 20, 20));
              layout.getChildren().addAll(fileInput, inputButton);
  
              //Set scene and show in window.
              Scene scene = new Scene(layout, 300, 100);
              window.setScene(scene);
              window.show();
  
          }
  
          Hangman newGame = new Hangman(inputFile.toString());
          welcomeLabel.setText("A word has been selected. Good luck, and may the odds ever be in your favor.");
  
          guessesLettersLabel.setText("Guessed Letters: " + newGame.getGuessedLetters());
          GuessesRemainingLabel.setText("Guesses remaining: " + newGame.getIncorrectGuessesRemaining());
          currentStateLAbel.setText("Current State: " + newGame.getCurrentState());
  
      }
  
      public void enterTextButton(){
          System.out.println("You pressed enter...");
      }
  
      public void enterText(){
          enterTextButton();
      }
  
      /**
       * If the player closed to exit the game or hit the X button this method will ask if they are
       * sure they wish to exit before quiting the game.
       */
      public void exitGame(){
          Boolean answer = desplayYesNoMessgae("Exit", "Are you sure you want to exit?");
          if(answer)
              System.exit(0);
      }
  
      public boolean desplayYesNoMessgae(String title, String message){
          Stage window = new  Stage();
          window.initModality(Modality.APPLICATION_MODAL);
          window.setTitle(title);
          window.setMinWidth(250);
          Label label1 = new Label();
          label1.setText(message);
  
          //Create two buttons, yes and no
          Button yesButton = new Button("Yes");
          Button noButton = new Button("No");
  
          //If yes ic clucked, set answer to true.
          yesButton.setOnAction(e -&gt; {
              ynAnswer = true;
              window.close();
          });
  
          //if no is clicked, set answer to false.
          noButton.setOnAction(e -&gt; {
              ynAnswer =  false;
              window.close();
          });
  
          VBox layout = new VBox(10);
          layout.getChildren().addAll(label1, yesButton, noButton);
          layout.setAlignment(Pos.CENTER);
          Scene scene = new Scene(layout);
          window.setScene(scene);
          window.showAndWait();
  
          return ynAnswer;
      }
  
      public String desplayTextMessgae(String title, String message){
          Stage window = new  Stage();
          window.initModality(Modality.APPLICATION_MODAL);
          window.setTitle(title);
          window.setMinWidth(250);
          Label label1 = new Label();
          label1.setText(message);
  
          //form
          TextField nameInput = new TextField();
          Button loadBbutton = new Button("Upload");
          loadBbutton.setOnAction(e -&gt; {
              textAnswer = nameInput.getText();
              window.close();
          });
  
  
          //Layout
          VBox layout = new VBox(10);
          layout.setPadding(new Insets(20, 20, 20, 20));
          layout.getChildren().addAll(nameInput, loadBbutton);
  
          //Set scene and show in window.
          Scene scene = new Scene(layout, 300, 100);
          window.setScene(scene);
          window.show();
  
          return textAnswer;
      }
  
  }
  </code></pre>