本文整理汇总了Java中javafx.scene.control.Alert.AlertType.CONFIRMATION属性的典型用法代码示例。如果您正苦于以下问题:Java AlertType.CONFIRMATION属性的具体用法?Java AlertType.CONFIRMATION怎么用?Java AlertType.CONFIRMATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javafx.scene.control.Alert.AlertType
的用法示例。
在下文中一共展示了AlertType.CONFIRMATION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayDeleteGameAlert
public static void displayDeleteGameAlert() {
int index = -1;
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setHeaderText(null);
alert.setContentText("Are you sure you want to delete the selected games?");
ButtonType deleteGame = new ButtonType("Delete Game(s)");
ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(deleteGame, buttonTypeCancel);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == deleteGame){
for (String g : selectedGamesString) {
index = getGameIndex(g);
gameList.getGameList().remove(index);
}
refreshGameList();
deleteButton.setDisable(true);
}
else {
// ... user chose CANCEL or closed the dialog
}
}
示例2: handleOpen
@FXML
private void handleOpen() {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirmation Dialog");
alert.setHeaderText("Do you want to save your current changes?");
alert.setContentText("");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
File entryFile = mainApp.getFilePath();
mainApp.saveEntryDataToFile(entryFile);
}
FileChooser fileChooser = new FileChooser();
// set extension filter
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XML files (*.xml)", "*.xml");
fileChooser.getExtensionFilters().add(extFilter);
// show open file dialog
File file = fileChooser.showOpenDialog(mainApp.getPrimaryStage());
if (file != null) {
mainApp.loadEntryDataFromFile(file);
}
}
示例3: showPropertyContainerEditor
public static void showPropertyContainerEditor(Window owner, KlcPropertyContainer propertyContainer, String title,
String headerText, String contentText) {
Alert alert = new Alert(AlertType.CONFIRMATION, contentText, ButtonType.OK);
alert.setTitle(title);
alert.setHeaderText(headerText);
alert.initOwner(owner);
alert.initModality(Modality.WINDOW_MODAL);
KlcPropertyContainerEditor editor = new KlcPropertyContainerEditor();
editor.setPrefWidth(300);
editor.setPrefHeight(200);
editor.setPropertyContainer(propertyContainer);
alert.getDialogPane().setContent(editor);
alert.showAndWait();
}
示例4: saveOnExit
public void saveOnExit() {
if (!taNoteText.getText().equals(this.note.getText())) {
if (!JGMRConfig.getInstance().isDontAskMeToSave()) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Save notes?");
alert.setHeaderText("Would you like to save your notes?");
ButtonType save = new ButtonType("Save");
ButtonType dontaskmeagain = new ButtonType("Don't ask me again");
ButtonType dontsave = new ButtonType("Don't save", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(save, dontaskmeagain, dontsave);
Optional<ButtonType> result = alert.showAndWait();
if(result.get() == save){
save();
}else if(result.get() == dontaskmeagain){
JGMRConfig.getInstance().setDontAskMeToSave(true);
save();
}
} else {
save();
}
}
}
示例5: onEditButtonClicked
public void onEditButtonClicked() {
boolean isGoodInput = true;
double d = 0;
try {
d = Double.valueOf(editPriceField.getText());
} catch (NumberFormatException e) {
isGoodInput = false;
}
if (isGoodInput == true) {
RoomService roomservice = new RoomService();
Alert a = new Alert(AlertType.CONFIRMATION);
a.setTitle("Price Change Confirmation");
a.setHeaderText("Confirm the Price Change?");
Optional<ButtonType> result = a.showAndWait();
if (result.get() == ButtonType.OK) {
roomservice.editRoomPrice(EditPricesScreenController.service, d);
Stage dialogStage = (Stage) cancelButton.getScene().getWindow();
dialogStage.close();
ScreenManager.getInstance().switchToScreen("/fxml/EditPricesScreen.fxml");
}
}
}
示例6: mnuUndo
@FXML
private void mnuUndo(ActionEvent event) {
Stage AboutStage = (Stage) btnSignOut.getScene().getWindow();
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Action Failed");
alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
alert.setX(AboutStage.getX() + 60);
alert.setY(AboutStage.getY() + 170);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
(new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
(new GoToOperation()).goToMakeATransaction(AboutStage.getX(), AboutStage.getY());
AboutStage.close();
}
}
示例7: onClickRestore
/**
* Restores all settings to default. Some settings like {@link Property#DEVELOPMENT} and
* {@link Property#SHOW_CHANGELOG} won't be reset, since the user can't change those anyways.
*/
@SuppressWarnings("static-method") // Can't be static because of FXML injection
@FXML
private void onClickRestore() {
final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToRestoreSettings"), ButtonType.YES, ButtonType.NO);
alert.setTitle(Client.lang.getString("restoreSettingsToDefault"));
Client.insertAlertOwner(alert);
final Optional<ButtonType> result = alert.showAndWait();
result.ifPresent(button -> {
if (button == ButtonType.YES) {
restoreApplicationSettings();
LegacySettingsController.restoreLegacySettings();
// Reapply theme, since it might have been changed
Client.getInstance().applyTheme();
// Assure the view that the displays the correct data.
Client.getInstance().reloadViewIfLoaded(View.SETTINGS);
}
});
}
示例8: optionsAlert
/**
* Display an option Alert to verify user selection.
* @param message The message to be displayed at the window.
* @return an <code>integer</code> specifying if user wants to proceed or not.
*/
public int optionsAlert(String message){
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Delete permanetly");
alert.setHeaderText(null);
alert.setContentText(message);
ButtonType button1 = new ButtonType("Yes");
ButtonType button2 = new ButtonType("No");
alert.getButtonTypes().setAll(button2, button1);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == button1)
return 1; //1 == delete
else
return 0; //0 == don't delete
}
示例9: nextLevel
public void nextLevel(){
if(!(currentLevel == numLevels)){
Alert winAlert = new CustomAlert(AlertType.CONFIRMATION, "You beat the level!");
winAlert.setOnCloseRequest(e -> bus.emit(new GamePauseResumeEvent()));
winAlert.show();
bus.emit(new GamePauseResumeEvent());
///System.out.println("next level loading");
currentLevel++;
//System.out.println("Current level: " + currentLevel);
loadLevel(data.get(currentLevel-1));
return;
}
new WinPresentation().show(new ResultAccessor());;
bus.emit(new WinGameEvent(WinGameEvent.WIN));
bus.emit(new GamePauseResumeEvent());
}
示例10: confirm
public static void confirm(Window owner, String title, String headerText, String contentText, Runnable onConfirm) {
Alert alert = new Alert(AlertType.CONFIRMATION);
setupDialog(owner, title, headerText, contentText, alert);
alert.showAndWait().ifPresent(bt -> {
if (bt == ButtonType.OK) {
onConfirm.run();
}
});
}
示例11: deleteSelectedFavourites
private void deleteSelectedFavourites() {
final Alert alert = new Alert(AlertType.CONFIRMATION, Client.lang.getString("sureYouWantToDeleteFavourites"), ButtonType.YES, ButtonType.NO);
Client.insertAlertOwner(alert);
alert.setTitle(Client.lang.getString("deleteFavourites"));
final Optional<ButtonType> result = alert.showAndWait();
result.ifPresent(buttonType -> {
if (buttonType == ButtonType.YES) {
final List<SampServer> serverList = getSelectionModel().getSelectedItems();
serverList.forEach(FavouritesController::removeServerFromFavourites);
servers.removeAll(serverList);
}
});
}
示例12: alertConfirm
public int alertConfirm() {
int r = 0;
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("확인 알림");
alert.setHeaderText(null);
alert.setContentText(this.msg);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
r = 1;
}
return r;
}
示例13: onCancelBookingButtonClicked
/**
* Displays a confirmation dialog showing the price that will be charged as a cancellation fee.
*/
@FXML
private void onCancelBookingButtonClicked() {
double cancellationFee = BookingService.calcCancellationFee(this.booking);
String cancellationFeeString = String.format("$%.2f", cancellationFee);
// Show confirmation dialog
Alert confirmationDialog = new Alert(AlertType.CONFIRMATION);
confirmationDialog.setTitle("Confirm");
confirmationDialog.setHeaderText("Confirm Cancel Booking");
// Check for the case where there is no fee because of the 24 hr window
if(cancellationFee < 0.01) {
confirmationDialog.setContentText("You will not be assessed a cancellation fee."
+ " - please confirm that you want to cancel this booking."
+ " This action cannot be undone.");
} else {
confirmationDialog.setContentText("You will be assessed a cancellation fee of "
+ cancellationFeeString
+ " - please confirm that you want to cancel this booking. "
+ "This action cannot be undone.");
}
// Show the dialog and get the result
Optional<ButtonType> result = confirmationDialog.showAndWait();
if(result.get() == ButtonType.OK) {
// User chose OK
BookingService bookingService = new BookingService();
bookingService.cancelBooking(this.booking);
bookingCanceledLabel.setVisible(true);
}
}
示例14: confirm
public static boolean confirm(String title,String header,String body){
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(title);
alert.setHeaderText(header);
alert.setContentText(body);
Optional<ButtonType> result = alert.showAndWait();
return result.get() == ButtonType.OK;
}
示例15: binaryChoiceAlert
/**
* Creates a YES/NO alert (buttons included).
* @param header The alert header message
* @param message The alert body message
* @return An alert dialog with the Yes and No buttons.
*/
public static Alert binaryChoiceAlert(String header, String message) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirm action");
alert.setHeaderText(header);
alert.setContentText(message);
ButtonType[] buttons = new ButtonType[] {
ButtonType.YES,
ButtonType.NO
};
alert.getButtonTypes().setAll(buttons);
return alert;
}