List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:headhunt.fx.setup.SetupPresenter.java
@FXML private void next() { if (model.viewIndex == 1 && !model.userAgreeWithTerms()) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("WARNING"); alert.setHeaderText("LicenseCtrl agreement."); alert.setContentText("You must agree with the application terms\nto procede further."); alert.showAndWait();// w ww. j a v a 2 s . c o m return; } if (model.viewIndex == 2 && model.pathExists()) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("WARNING"); alert.setHeaderText("ERR: Selected directory"); alert.setContentText( "One or more folders with the name 'headhunt'\nalready exist, select other directory!"); alert.show(); return; } previousButton.setDisable(false); if (model.viewIndex + 1 != view.getChildren().size()) { view.getChildren().get(model.viewIndex).setVisible(false); model.viewIndex++; view.getChildren().get(model.viewIndex).setVisible(true); } if (model.viewIndex == view.getChildren().size() - 1) { nextButton.setDisable(true); finishButton.setDisable(false); } }
From source file:account.management.controller.AddLocationController.java
@FXML private void onSubmitButtonClick(ActionEvent event) { String name = ""; if (this.input_name.getText().equals("")) { Msg.showError("Please enter location name"); return;/* w ww . j av a2 s.c o m*/ } else { name = this.input_name.getText(); } String details = ""; if (!this.input_details.getText().equals("")) { details = input_details.getText(); } button_submit.setDisable(true); try { Unirest.get(MetaData.baseUrl + "add/location").queryString("name", name).queryString("details", details) .asJson(); button_submit.setDisable(false); Msg.showInformation(""); this.button_submit.getScene().getWindow().hide(); } catch (UnirestException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error in the server. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:de.fraunhofer.iosb.ilt.stc.FXMLController.java
@FXML private void actionLoad(ActionEvent event) { fileChooser.setTitle("Load Config"); File file = fileChooser.showOpenDialog(paneConfig.getScene().getWindow()); try {//from w w w . j av a 2s . c o m String config = FileUtils.readFileToString(file, "UTF-8"); JsonElement json = new JsonParser().parse(config); copier.configure(json, null, null); } catch (IOException ex) { LOGGER.error("Failed to read file", ex); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("failed to read file"); alert.setContentText(ex.getLocalizedMessage()); alert.showAndWait(); } }
From source file:net.thirdy.blackmarket.controls.Dialogs.java
public static void showInfo(String string) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText(""); alert.setContentText(string);// w ww . j a v a 2s.c om alert.showAndWait(); }
From source file:gallerydemo.menu.ManagementMenuController.java
public ManagementMenuController(GalleryDemoViewController controller) { super(controller, "ManagementMenu.fxml"); this.actualizeButtons(); this.newGalleryButton.setOnAction((ActionEvent event) -> { this.createGalleryOrFolder(true); });/*from w w w . j a v a2 s . c o m*/ this.newFolderButton.setOnAction((ActionEvent event) -> { this.createGalleryOrFolder(false); }); this.galleryPropertiesButton.setOnAction((ActionEvent event) -> { GalleryNode g = this.controller.getActiveGallery(); if (g.isTrunk()) { return; } TextInputDialog dialog = new TextInputDialog(g.getName()); dialog.setTitle("Umbenennen"); dialog.setHeaderText( g.isGallery() ? "Die ausgewhlte Galerie umbenennen" : "Den ausgewhlten Ordner umbenennen"); dialog.setContentText("Neuer Name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { g.setName(result.get()); g.saveConfigFile(); } }); this.deleteGalleryButton.setOnAction((ActionEvent event) -> { GalleryNode g = this.controller.getActiveGallery(); if (g.isTrunk()) { return; } Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Lschen"); alert.setHeaderText( g.isGallery() ? "Die ausgewhlte Galerie lschen?" : "Den ausgewhlten Ordner lschen?"); alert.setContentText("Unwiederruflicher Vorgang!"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { GalleryNode parent = (GalleryNode) g.getParent(); Logger.getLogger("logfile").log(Level.INFO, "[delete] {0}", g.getLocation()); try { FileUtils.deleteDirectory(g.getLocation()); } catch (IOException ex) { Logger.getLogger("logfile").log(Level.SEVERE, null, ex); } finally { // Remove deleted gallery from tree view parent.getChildren().remove(g); this.controller.setActiveGallery(parent); } } }); }
From source file:com.canoo.dolphin.todo.client.ToDoClient.java
private void showError(String header, String content, Exception e) { e.printStackTrace();//from w ww.j a v a2 s . c o m Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText(header); alert.setContentText(content); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); System.exit(-1); }
From source file:account.management.controller.inventory.StockReportController.java
@Override public void initialize(URL url, ResourceBundle rb) { product_list = FXCollections.observableArrayList(); try {/*w w w .j av a2 s . c o m*/ HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "all/products").asJson(); JSONArray array = res.getBody().getArray(); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); int id = obj.getInt("id"); String name = obj.getString("name"); float p_qty = Float.parseFloat(obj.get("p_qty").toString()); float s_qty = Float.parseFloat(obj.get("s_qty").toString()); double last_p_rate = obj.getDouble("last_p_rate"); double last_s_rate = obj.getDouble("last_s_rate"); double avg_p_rate = obj.getDouble("avg_p_rate"); double avg_s_rate = obj.getDouble("avg_s_rate"); product_list .add(new Product(id, name, p_qty, s_qty, last_p_rate, last_s_rate, avg_p_rate, avg_s_rate)); } } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error in the server. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:net.thirdy.blackmarket.controls.Dialogs.java
public static void showInfo(String string, String title) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(title);// www .j a v a2s. c o m alert.setHeaderText(""); alert.setContentText(string); alert.showAndWait(); }
From source file:account.management.controller.inventory.ProductWiseInventoryReportController.java
/** * Initializes the controller class.// ww w .j a v a 2 s .com */ @Override public void initialize(URL url, ResourceBundle rb) { new AutoCompleteComboBoxListener<>(item); item.setOnHiding((e) -> { Product a = item.getSelectionModel().getSelectedItem(); item.setEditable(false); item.getSelectionModel().select(a); }); item.setOnShowing((e) -> { item.setEditable(true); }); // get product list products_list = FXCollections.observableArrayList(); try { HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "all/products").asJson(); JSONArray array = res.getBody().getArray(); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); int id = obj.getInt("id"); String name = obj.getString("name"); products_list.add(new Product(id, name)); } this.item.getItems().addAll(products_list); } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error in the server. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:de.hs.mannheim.modUro.controller.diagram.ModeltypeDiagramController.java
public void init(ModelType modeltype) { this.modeltypeDiagram = new ModeltypeDiagram(modeltype); if (leftLastSelectedIndex == null || rightLastSelectedIndex == null) { initializeChoiceboxContent();/* w w w . j a v a 2s .c om*/ } else { if (simulationContainsMetricType()) { setChoiceBoxContent(); setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex)); setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex)); } else { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Warning"); alert.setHeaderText("Metrictype Warning"); alert.setContentText("Simulation does not have Metrictype: " + leftLastSelectedMetrictypename); alert.showAndWait(); initializeChoiceboxContent(); } } /*ChangeListerners for selected items in choicebox.*/ leftMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); leftLastSelectedIndex = newValue.intValue(); leftLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex); } }); rightMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); rightLastSelectedIndex = newValue.intValue(); rightLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex); } }); }