當前位置: 首頁>>代碼示例>>Java>>正文


Java AlertType.CONFIRMATION屬性代碼示例

本文整理匯總了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
    }
}
 
開發者ID:Stevoisiak,項目名稱:Virtual-Game-Shelf,代碼行數:26,代碼來源:GameShelf.java

示例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);
	}
}
 
開發者ID:yc45,項目名稱:kanphnia2,代碼行數:26,代碼來源:RootLayoutController.java

示例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();

}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:18,代碼來源:DialogUtil.java

示例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();
        }
    }
}
 
開發者ID:eternia16,項目名稱:javaGMR,代碼行數:23,代碼來源:TexteditorController.java

示例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");
        }
    }
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:23,代碼來源:EditPricesDialogController.java

示例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();
	}
}
 
開發者ID:krHasan,項目名稱:Money-Manager,代碼行數:16,代碼來源:AboutController.java

示例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);
		}
	});
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:25,代碼來源:SettingsController.java

示例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
}
 
開發者ID:pxndroid,項目名稱:mountieLibrary,代碼行數:22,代碼來源:MainWindowController.java

示例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());

}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:17,代碼來源:LevelManager.java

示例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();
		}
	});
}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:10,代碼來源:DialogUtil.java

示例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);
		}
	});
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:14,代碼來源:SampServerTable.java

示例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;
}
 
開發者ID:kimyearho,項目名稱:WebtoonDownloadManager,代碼行數:14,代碼來源:AlertSupport.java

示例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);
    }
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:33,代碼來源:BookingDetailsScreenController.java

示例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;
}
 
開發者ID:eacp,項目名稱:Luna-Exam-Builder,代碼行數:9,代碼來源:Dialogs.java

示例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;
}
 
開發者ID:vibridi,項目名稱:fxutils,代碼行數:20,代碼來源:FXDialog.java


注:本文中的javafx.scene.control.Alert.AlertType.CONFIRMATION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。