本文整理汇总了Java中javafx.scene.control.Alert.AlertType.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java AlertType.ERROR属性的具体用法?Java AlertType.ERROR怎么用?Java AlertType.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javafx.scene.control.Alert.AlertType
的用法示例。
在下文中一共展示了AlertType.ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editWSPAction
private void editWSPAction(Event e) {
EditWSPDialog dialog = new EditWSPDialog(wsp);
Optional<WebServiceProvider> result = dialog.showAndWait();
if (result.isPresent()) {
try {
wsp = result.get();
wsp.fetchConfiguration();
writeWSP(wsp);
} catch (JSONException | WebApiException | IOException | HttpException e1) {
Alert a = ErrorUtils.getAlertFromException(e1);
a.show();
e1.printStackTrace();
}
} else {
new Alert(AlertType.ERROR, "Wrong WSP information");
}
}
示例2: showAlertDialogue
/**
* Spawns an error dialogue detailing the given exception.
* <p>
* The given message will be used as the dialogue's header, and the exception's stack
* trace will appear in the hidden "more information" dropdown.
* <p>
* If the exception has a message, it will be displayed in the dialogue's content
* field, prefaced by "Cause:"
*
* @param exception
* The exception to display
* @param message
* A message to describe the context of the dialogue, usually why the
* dialogue is appearing (e.g. "An error has occurred!")
*/
public static void showAlertDialogue(Exception exception, String message)
{
String context = exception.getMessage();
boolean valid = (context != null && !context.isEmpty());
context = (valid) ? "Cause: " + context : null;
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Exception Dialog");
alert.setHeaderText(message);
alert.setContentText(context);
alert.setGraphic(null);
String exceptionText = getStackTraceAsString(exception);
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(false);
alert.getDialogPane().setExpandableContent(textArea);
alert.showAndWait();
}
示例3: alertErrorConfirm
public int alertErrorConfirm() {
int r = 0;
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("경고");
alert.setHeaderText(null);
alert.setContentText(this.msg);
alert.showAndWait();
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
r = 1;
}
return r;
}
示例4: saveEntryDataToFile
public void saveEntryDataToFile(File f) {
try {
JAXBContext context = JAXBContext.newInstance(EntryListWrapper.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// wrapping the entry data
EntryListWrapper wrapper = new EntryListWrapper();
wrapper.setEntries(entryList);
// marshalling and saving xml to file
m.marshal(wrapper, f);
// save file path
setFilePath(f);
}
catch (Exception e) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Could not save data");
alert.setContentText("Could not save data to file:\n" + f.getPath());
alert.showAndWait();
}
}
示例5: removeServerAction
private void removeServerAction(Event e) {
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to remove this server ?");
Optional<ButtonType> result = conf.showAndWait();
if (result.isPresent() && result.get().equals(ButtonType.OK)) {
Server s = content.removeSelectedServer();
if (s != null) {
servers.remove(s);
ServerListLoader.writeServerList(servers);
} else
new Alert(AlertType.ERROR, "No selected server");
}
}
示例6: displayBookingHasAlreadyBeenCheckedInError
private void displayBookingHasAlreadyBeenCheckedInError() {
Alert errorDialog = new Alert(AlertType.ERROR);
errorDialog.setTitle("Error");
errorDialog.setHeaderText("Cannot check in the selected booking");
errorDialog.setContentText("This booking has already been checked in previously");
errorDialog.showAndWait();
}
示例7: errorAlert
/**
* Creates an error alert with an expandable section that shows a Java stack trace.
* @param header The alert header message (this is not the dialog title)
* @param message The alert body message
* @param t The Java throwable whose stack trace will appear in the expandable section.
* @return A JavafX error alert
*/
public static Alert errorAlert(String header, String message, Throwable t) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText(header);
alert.setContentText(message);
if(t != null)
alert.getDialogPane().setExpandableContent(createExpandableContent(t));
return alert;
}
示例8: error
private static void error(String title, String text) {
Alert alert = new Alert(AlertType.ERROR);
setIcon(alert);
alert.setTitle(title);
alert.setContentText(text);
alert.showAndWait();
}
示例9: ensureRequiredFieldsNotEmpty
private boolean ensureRequiredFieldsNotEmpty() {
// Gather trimmed form data from all required fields.
String firstName = firstNameField.getText().trim();
String lastName = lastNameField.getText().trim();
String addressLine1 = addressLine1Field.getText().trim();
String city = cityField.getText().trim();
String country = countryPicker.getValue();
String postalCode = postalCodeField.getText().trim();
boolean requiredFieldsNotEmpty = true; // Innocent until proven guilty
// Check if required fields are empty
if(firstName.isEmpty()
|| lastName.isEmpty()
|| addressLine1.isEmpty()
|| city.isEmpty()
|| country.isEmpty()
|| postalCode.isEmpty()) {
requiredFieldsNotEmpty = false;
}
if(requiredFieldsNotEmpty==false) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Missing Required Fields");
alert.setContentText("Please ensure all fields are filled.");
alert.showAndWait();
}
return requiredFieldsNotEmpty;
}
示例10: saveImage
@FXML
void saveImage() {
if (image == null) {
Alert a = new Alert(AlertType.ERROR);
a.setContentText("No image to export!");
a.show();
}
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialDirectory(Preferences.getPath("lastImageDir").toFile());
fileChooser.setTitle("Save image");
fileChooser.getExtensionFilters().addAll(
new ExtensionFilter("PNG Images", "*.png"));
File selected = fileChooser.showSaveDialog(getScene().getWindow());
if (selected != null) {
Preferences.setPath("lastImageDir", selected.toPath());
try {
ImageIO.write(image.toBufferedImage(), "png", selected);
} catch (IOException e) {
logger.error("Error while saving the image.", e);
ExceptionDialog exceptionDialog = new ExceptionDialog(e);
exceptionDialog.setTitle("Error");
exceptionDialog.setHeaderText("Error while saving the image.");
exceptionDialog.show();
}
}
}
示例11: handleAddStudentAction
@FXML
private void handleAddStudentAction(ActionEvent event) {
int studentId = 0;
try {
studentId = Integer.parseInt(studentIdField.getText());
} catch (NumberFormatException nfe) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error Message");
alert.setHeaderText("Incorrect student Id");
alert.setContentText("Student Id has to be an integer in the range[1, 1000]");
alert.showAndWait();
return;
}
String studentName = studentNameField.getText();
double cgpa = Double.parseDouble(cgpaField.getText());
try {
Connection connection = DriverManager
.getConnection("jdbc:mysql://172.17.0.119/spring2017db",
"javauser",
"java");
Statement statement = connection.createStatement();
String query = "INSERT INTO student VALUES(" + studentId
+ ", '" + studentName + "', " + cgpa + ")";
System.out.println(query);
statement.executeUpdate(query);
Student student = new Student(studentId, studentName, cgpa);
studentsList.add(student);
statusLabel.setText("Added a new entry for " + studentName);
studentIdField.clear();
studentNameField.clear();
cgpaField.clear();
} catch (SQLException sqle) {
}
}
示例12: showError
private void showError(String title, String message) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}
示例13: displayErrorPopup
protected static void displayErrorPopup(Throwable errorToDisplay, String initialMessage) {
Alert alert = new Alert(AlertType.ERROR, initialMessage + errorToDisplay.getMessage());
GridPane expContent = createExceptionTextArea(errorToDisplay);
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
示例14: alertErrorMsg
public void alertErrorMsg(Stage stage) {
Alert alert = new Alert(AlertType.ERROR);
alert.initOwner(stage);
alert.setTitle("Warning Dialog");
alert.setHeaderText(null);
alert.setContentText(this.msg);
alert.showAndWait();
}
示例15: errorPopUp
public Alert errorPopUp(String message){
Alert errorAlert=new Alert(AlertType.ERROR);
errorAlert.setHeaderText(message);
return errorAlert;
}