本文整理匯總了Java中javafx.scene.control.Alert.getResult方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.getResult方法的具體用法?Java Alert.getResult怎麽用?Java Alert.getResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.getResult方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionDelete
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@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: onSubmitClicked
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Action button for when submit button is clicked.
*
* @throws IOException
*/
public void onSubmitClicked() throws IOException {
if (!feedbackTextArea.getText().isEmpty()
&& !guestEmailTextField.getText().isEmpty()) {
GuestFeedbackService guestfeedbackservice = new GuestFeedbackService();
guestfeedbackservice.createNewGuestFeedback(
new GuestFeedback(feedbackTextArea.getText(), guestEmailTextField.getText())
);
// Display an alert dialog to confirm the submission.
Alert a = new Alert(AlertType.INFORMATION);
a.setTitle("Thanks!");
a.setHeaderText("Thanks for your feedback. As promised, we will now ignore it.");
a.showAndWait();
if (a.getResult() == ButtonType.OK) {
// User clicked OK
onCancelClicked(); // This just closes the dialog, but it's a bit hacky
}
}
}
示例3: askIfOk
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static boolean askIfOk(String msg) {
Alert dialog = new Alert(AlertType.CONFIRMATION);
dialog.setTitle("Confirmation");
dialog.setResizable(true);
dialog.setContentText(msg);
dialog.setHeaderText(null);
dialog.showAndWait();
return dialog.getResult() == ButtonType.OK;
}
示例4: showConfirmationMessage
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static ButtonType showConfirmationMessage(String confirmationMessage) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Planchester Message");
alert.setHeaderText(confirmationMessage);
alert.getButtonTypes().clear();
alert.getButtonTypes().add(ButtonType.YES);
alert.getButtonTypes().add(ButtonType.NO);
alert.showAndWait();
return alert.getResult();
}
示例5: showPublishConfirmationMessage
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static ButtonType showPublishConfirmationMessage(String confirmationMessage) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Planchester Message");
alert.setHeaderText(confirmationMessage);
alert.getButtonTypes().clear();
alert.getButtonTypes().add(new ButtonType("Cancel"));
alert.getButtonTypes().add(new ButtonType("Publish"));
alert.showAndWait();
return alert.getResult();
}
示例6: showLogoutUserMessage
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public static ButtonType showLogoutUserMessage() {
Alert alert = new Alert(Alert.AlertType.NONE);
alert.setTitle("Planchester Logout");
alert.setHeaderText("Are you sure that you want to log out and close Planchester?");
alert.getButtonTypes().clear();
alert.getButtonTypes().add(new ButtonType("Switch User"));
alert.getButtonTypes().add(new ButtonType("Logout & Close"));
alert.getButtonTypes().add(new ButtonType("Cancel"));
alert.showAndWait();
return alert.getResult();
}