IntField endingNumber = new IntField(startingNumber.getValue(), 999999, startingNumber.getValue() + 1); ButtonType printButtonType = new ButtonType("Print", ButtonData.OK_DONE); Stage stage; .ifPresent(result -> { endingNumber.setValue(startingNumber.getValue() + 1); printChecks(startingNumber.getValue(), endingNumber.getValue()); }); }); Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Has the last check, the number: " + endingNumber.getValue() + "?", ButtonType.YES, ButtonType.NO); alert.initOwner(stage); Button btnNo = (Button) alert.getDialogPane().lookupButton(ButtonType.NO);