I'm new to JavaFx and I'm trying to create a class of a simple confirmation box that determines whether the user really wants to exit or not. It has one function that returns a boolean value, representing if the user clicked "yes" or "no":
public class ConfirmBoxController implements IView {
    public javafx.scene.control.Button yes_BTN;
    public javafx.scene.control.Button no_BTN;
    private volatile boolean answer;
    // Constructors..//
    public boolean confirm(){
        try{
            stage = new Stage();
            FXMLLoader fxmlLoader = new FXMLLoader();
            Parent root = fxmlLoader.load(getClass().getResource("ConfirmBox.fxml").openStream());
            Scene scene = new Scene(root, 250, 140);
            stage.setScene(scene);
            stage.showAndWait();
            return answer;
        }
        catch(Exception E){
            E.printStackTrace();
            return true;
        }
    }
    public void yes() {
        this.answer = true;
        Stage stage = (Stage) yes_BTN.getScene().getWindow();
        stage.close();
    }
    public void no() {
        this.answer = false;
        Stage stage = (Stage) no_BTN.getScene().getWindow();
        stage.close();
    }
}
I tried making "answer" volatile and not, but it didn't change anything.
 
     
    