'Changing scenes with Alert JavaFX
I'm using JavaFX and trying to make a small GUI application where the user can interact with spacetraders.io API. I've implemented an Alert dialog box when the user attempts to make any transaction (purchase a ship, obtain a loan, purchase goods, sell goods...), and once the user has confirmed their transaction, the stage will be switched to a stage that displays the results of the transaction when shown.
The Alert dialog box functions fine but the switching of stage presents an issue. When I switch the stage, the full scene is not loaded for some odd reason, the back button is chopped off.
When I then click anywhere on the window, the stage is fully shown as in the first image. (all it takes is one click anywhere inside the window).
When I remove the Alert, the stage loads fine. But when I put the same code into an ifPresent lambda, the stage fails to load fully/properly.
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Are you sure you want to obtain this loan?");
alert.showAndWait().ifPresent(response -> {
if (response == ButtonType.OK) {
BorderPane borderPane = new BorderPane();
//make title, backbtn, res
borderPane.setTop(title);
borderPane.setBottom(backBtn);
borderPane.setCenter(res);
Scene scene = new Scene(borderPane, 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
event.consume();
}
});
I've looked at the docs and I can't seem to figure out why this is the case? Any solutions are welcome?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
