本文整理匯總了Java中javafx.scene.control.ButtonType.NO屬性的典型用法代碼示例。如果您正苦於以下問題:Java ButtonType.NO屬性的具體用法?Java ButtonType.NO怎麽用?Java ButtonType.NO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javafx.scene.control.ButtonType
的用法示例。
在下文中一共展示了ButtonType.NO屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionDelete
@FXML
private void actionDelete(ActionEvent event) {
if (!canDelete) {
return;
}
EntityListEntry selectedItem = entityList.getSelectionModel().getSelectedItem();
Entity entity = selectedItem.getEntity();
if (entity.getId() == null) {
// entity doesn't exist yet.
entities.remove(selectedItem);
return;
}
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Delete " + entity.getId().toString() + " ?", ButtonType.YES, ButtonType.NO);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
try {
entity.getService().delete(entity);
entities.remove(selectedItem);
} catch (ServiceFailureException ex) {
LOGGER.warn("Failed to delete entity.", ex);
}
}
}
示例2: newFile
@FXML
public void newFile() {
Alert closeConfirmation = new Alert(
Alert.AlertType.CONFIRMATION,
"Create a new station?",
ButtonType.YES,
ButtonType.NO
);
closeConfirmation.setHeaderText("New station");
closeConfirmation.initModality(Modality.APPLICATION_MODAL);
closeConfirmation.initOwner(root.getScene().getWindow());
Optional<ButtonType> closeResponse = closeConfirmation.showAndWait();
if (ButtonType.YES.equals(closeResponse.get())) {
station = new Station();
updateEditors();
updateTitle();
}
}
示例3: shortcutDelete
private void shortcutDelete(int index, ObservableGanttTask obs) {
if(index == -1 || obs == null) {
index = getSelectionModel().getSelectedIndex();
obs = getSelectionModel().getSelectedItem();
}
if(obs == null || index == 0)
return;
if(obs.getTask().size() > 0) {
ButtonType type = FXDialog.binaryChoiceAlert("This will delete also all sub-tasks. Proceed?").showAndWait().get();
if(type == ButtonType.NO)
return;
}
removeTask(index);
}
示例4: 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);
}
});
}
示例5: 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;
}
示例6: createAlert
private static Alert createAlert(String titleKey, String messageKey, AlertType alertType) {
String title = I18n.getString(titleKey);
String message = I18n.getString(messageKey);
ButtonType[] buttons = alertType == CONFIRMATION || alertType == WARNING ?
new ButtonType[]{ButtonType.YES, ButtonType.NO} : new ButtonType[]{ButtonType.OK};
Alert alert = new Alert(alertType, message, buttons);
alert.setTitle(title);
alert.setHeaderText(null);
return alert;
}
示例7: confirm
/**
* Confirm box with 'Yes' or 'No' as available options
*
* @param message message to be displayed
* @return true for yes, false for no.
*/
public static boolean confirm(String message)
{
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, message, ButtonType.YES, ButtonType.NO);
alert.showAndWait();
return alert.getResult().equals(ButtonType.YES);
}
示例8: shutdown
private void shutdown(Stage mainWindow) {
// you could also use your logout window / whatever here instead
Alert alert = new Alert(Alert.AlertType.NONE, "Exit Kanphnia2?", ButtonType.YES, ButtonType.NO);
alert.setTitle("Confirm Exit");
if (alert.showAndWait().orElse(ButtonType.NO) == ButtonType.YES) {
// you may need to close other windows or replace this with Platform.exit();
mainWindow.close();
}
}
示例9: 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);
}
});
}
示例10: show
/**
* Shows the alert
* @return <code>true</code> if "Yes" was pressed, else return false
*/
public boolean show(){
alert = new Alert(Alert.AlertType.CONFIRMATION, question, ButtonType.YES, ButtonType.NO);
alert.initStyle(style);
Optional<ButtonType> result = alert.showAndWait();
if (result.isPresent()) if (result.get() == ButtonType.YES) return true;
return false;
}