List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:ExcelFx.XLSSettingController.java
@FXML protected void okButton(ActionEvent event) throws IOException { DropShadow ds = new DropShadow(); ds.setColor(Color.RED);/*from w w w. j a v a 2s. c om*/ String err = ""; try { if (pageField.getText().length() == 0) { err += " "; pageField.setEffect(ds); } } catch (Exception ex) { err += " "; pageField.setEffect(ds); } try { if (eddWayField.getText().length() == 0) { err += "? "; eddWayField.setEffect(ds); } } catch (Exception e) { err += "? "; eddWayField.setEffect(ds); } try { if (proffField.getText().length() == 0) { err += "??? "; proffField.setEffect(ds); } } catch (Exception ex) { err += "??? "; proffField.setEffect(ds); } // try { // if (eddNameField.getText().length() == 0) { // err += "? ? "; // eddNameField.setEffect(ds); // } // } catch (Exception ex) { // err += "??? "; // eddNameField.setEffect(ds); // } if (err.length() != 0) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText("? ?"); alert.setContentText(err); alert.showAndWait(); } else { json.setPage(pageField.getText().trim().toLowerCase()); json.setEddWay(eddWayField.getText().trim().toLowerCase()); json.setProffName(proffField.getText().trim().toLowerCase()); // json.setEddName(this.eddNameField.getText().trim().toLowerCase()); gridPane.setUserData(json); Stage stage = (Stage) gridPane.getScene().getWindow(); stage.close(); } switch (type) { case "university": { json.jsonCreate("university.json"); break; } case "college": { json.jsonCreate("college.json"); break; } } }
From source file:com.playonlinux.javafx.mainwindow.library.ViewLibrary.java
private void runConsole() { try {// w w w . ja v a 2 s . c om createNewTab(new ConsoleTab(jythonInterpreterFactory)); } catch (CommandInterpreterException e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(translate("Error while trying to run the console.")); alert.setContentText("The error was: " + ExceptionUtils.getFullStackTrace(e)); LOGGER.warn("Error while trying to run the console", e); } }
From source file:account.management.controller.inventory.PurchaseReportController.java
@FXML private void onShowReportButtonClick(ActionEvent event) { this.show.setDisable(true); try {//from www. j a v a2s. c om String id = String.valueOf(this.item.getSelectionModel().getSelectedItem().getId()); String start_date = "1980-01-01", end_date = "2050-12-31"; start_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.start.getValue().toString())); end_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.end.getValue().toString())); HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "report/ledger/purchase") .queryString("id", id).queryString("start", start_date).queryString("end", end_date).asJson(); JSONArray array = res.getBody().getArray(); System.out.println(array); Vector v = new Vector(); HashMap params = new HashMap(); params.put("date", "From " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(start_date)) + " To " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(end_date))); params.put("item_name", "Purchase report of " + this.item.getSelectionModel().getSelectedItem().getName()); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String date = obj.getString("date"); String quantity = obj.get("quantity").toString(); String rate = obj.get("rate").toString(); v.add(new SellPurchaseLedger(date, quantity, rate)); } Report report = new Report(); report.getReport("src\\report\\SellPurchaseLedger.jrxml", new JRBeanCollectionDataSource(v), params, "Purchase Report"); this.show.setDisable(false); } catch (Exception e) { System.out.println("Exception in show report button click"); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
@Override ContextMenu createContextMenu() {//from ww w .ja v a 2 s . c o m final ContextMenu cm = new ContextMenu(); MenuItem mi = new MenuItem("Create edge from here"); mi.setGraphic(Icons.getIconGraphics("bullet_go")); mi.setOnAction(event -> { final AutomatonEdgeBuilder newEdge = new AutomatonEdgeBuilder(this.getGraph()); this.getGraph().startDrawingConnector(this, newEdge); }); cm.getItems().add(mi); mi = new MenuItem("Delete state"); mi.setGraphic(Icons.getIconGraphics("delete")); mi.setStyle("-fx-text-fill:#FF3030"); mi.setOnAction(event -> { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm"); alert.setHeaderText("You are about to delete the state."); alert.setContentText("Do you want to continue?"); alert.showAndWait().filter(response -> response == ButtonType.OK) .ifPresent(response -> this.removeNodeAndEdges()); }); cm.getItems().add(mi); return cm; }
From source file:account.management.controller.inventory.SellReportController.java
@FXML private void onShowReportButtonClick(ActionEvent event) { this.show.setDisable(true); try {/*ww w.j ava 2s. com*/ String id = String.valueOf(this.item.getSelectionModel().getSelectedItem().getId()); String start_date = "1980-01-01", end_date = "2050-12-31"; start_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.start.getValue().toString())); end_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.end.getValue().toString())); HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "report/ledger/sell").queryString("id", id) .queryString("start", start_date).queryString("end", end_date).asJson(); JSONArray array = res.getBody().getArray(); System.out.println(array); Vector v = new Vector(); HashMap params = new HashMap(); params.put("date", "From " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(start_date)) + " To " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(end_date))); params.put("item_name", "Purchase report of " + this.item.getSelectionModel().getSelectedItem().getName()); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String date = obj.getString("date"); String quantity = obj.get("quantity").toString(); String rate = obj.get("rate").toString(); v.add(new SellPurchaseLedger(date, quantity, rate)); } Report report = new Report(); report.getReport("src\\report\\SellPurchaseLedger.jrxml", new JRBeanCollectionDataSource(v), params, "Sell Report"); report.getReport("src\\report\\DepositVoucher.jrxml", new JRBeanCollectionDataSource(v), params, "Deposit Voucher"); this.show.setDisable(false); } catch (Exception e) { System.out.println("Exception in show report button click"); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } }
From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java
@FXML private void onSalvarActionEvent(ActionEvent event) { try (PrintWriter pw = new PrintWriter(file); CSVPrinter print = csvFormat.print(pw)) { for (CSVRow row : tableView.getItems()) { if (row.isEmpty()) { print.println();/*from ww w. j a v a2s . c om*/ } else { for (SimpleStringProperty column : row.getColumns()) { print.print(column.getValue()); } print.println(); } } print.flush(); setSaved(); } catch (Exception ex) { ex.printStackTrace(); Alert d = new Alert(Alert.AlertType.ERROR); d.setHeaderText("Ooops, no foi possvel salvar o arquivo " + (file != null ? file.getName() : ".")); d.setContentText(ex.getMessage()); d.setTitle("Erro"); d.initOwner(root.getScene().getWindow()); d.show(); } }
From source file:ubicrypt.UbiCrypt.java
@Override public void start(final Stage stage) throws Exception { setUserAgentStylesheet(STYLESHEET_MODENA); stage.setTitle("UbiCrypt"); anchor().setStage(stage);//from w w w . ja v a 2s. c o m try { final PGPKeyPair kp = encryptionKey(); encrypt(Collections.singletonList(kp.getPublicKey()), new ByteArrayInputStream(StringUtils.repeat("ciao", 1).getBytes())); } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Strong Encryption Required"); alert.setHeaderText("Install JCE Unlimited Strength Jurisdiction policy files"); alert.setContentText( "You can install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files, which are required to use strong encryption.\n" + "Download the files and instructions for Java 8.\n" + "Locate the jre\\lib\\security directory for the Java instance that the UbiCrypt is using.\n" + "For example, this location might be: C:\\Program Files\\Java\\jre8\\lib\\security.\n" + "Replace these two files with the .jar files included in the JCE Unlimited Strength Jurisdiction Policy Files download.\n" + "Stop and restart the UbiCrypt.\n\n\n\n\n\n"); ButtonType icePage = new ButtonType("Go to JCE download Page"); alert.getButtonTypes().addAll(icePage); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == icePage) { getHostServices().showDocument( "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html"); } Platform.exit(); } final File secFile = securityFile().toFile(); stage.setScene(anchor().show(secFile.exists() ? "login" : "createKey", getHostServices())); stage.show(); final UbiCrypt ubiCrypt = this; anchor().getPasswordStream().subscribeOn(Schedulers.io()).subscribe(pwd -> { final SpringApplication app = new SpringApplication(UbiConf.class, PathConf.class, UIConf.class); app.setRegisterShutdownHook(false); app.addInitializers(new FixPassPhraseInitializer(pwd)); app.setLogStartupInfo(true); ctx = app.run(); ctx.getAutowireCapableBeanFactory().autowireBean(ubiCrypt); ctx.getBeanFactory().registerSingleton("stage", stage); ctx.getBeanFactory().registerSingleton("hostService", getHostServices()); ctx.getBeanFactory().registerSingleton("osUtil", new OSUtil(getHostServices())); ControllerFactory cfactory = new ControllerFactory(ctx); StackNavigator navigator = new StackNavigator(null, "main", cfactory); stage.setScene(new Scene(navigator.open())); }); stage.setOnCloseRequest(windowEvent -> shutdown.run()); Runtime.getRuntime().addShutdownHook(new Thread(shutdown)); }
From source file:com.rcs.shoe.shop.fx.controller.ui.NewProductController.java
private void openProductFoundDialog() { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Ovaj reni broj je zauzet!"); alert.setHeaderText("Redni broj: " + produstNumber.textProperty().getValue() + " je zauzet!"); alert.setContentText("Da li elite da izmenite stanje za ovaj proizvod?"); ButtonType okButton = new ButtonType("Da", ButtonData.OK_DONE); ButtonType cancelButton = new ButtonType("Ne", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(okButton, cancelButton); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(uIConfig.getIcon()); Optional<ButtonType> result = alert.showAndWait(); if (result.get().getButtonData() == ButtonData.OK_DONE) { openEditForm();/*from ww w. java2 s. c o m*/ } }
From source file:de.perdoctus.ebikeconnect.gui.MainWindowController.java
public void showAbout() throws IOException { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.initOwner(tabPane.getScene().getWindow()); alert.initModality(Modality.WINDOW_MODAL); alert.setWidth(640);// ww w . j av a2 s. c o m alert.setTitle(rb.getString("application-name")); alert.setHeaderText(rb.getString("application-name") + " Version " + rb.getString("app-version")); final String aboutInfo = IOUtils.toString(getClass().getResourceAsStream("/about-info.txt"), "UTF-8"); alert.setContentText(aboutInfo); final String licenseInfo = IOUtils.toString(getClass().getResourceAsStream("/license-info.txt"), "UTF-8"); final Label label = new Label(rb.getString("licenses")); final TextArea licenses = new TextArea(licenseInfo); licenses.setMaxWidth(Double.MAX_VALUE); licenses.setEditable(false); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(licenses, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.show(); }
From source file:sendsms.FXMLDocumentController.java
private boolean isCorrectInput() { String mensaje = ""; if (textNumero.getText().toString().isEmpty()) { mensaje += "Rellene el campo nmero"; } else {/*from w w w .jav a 2 s . co m*/ try { Integer.parseInt(textNumero.getText().toString()); } catch (NumberFormatException numberFormatException) { mensaje += "El nmero no puede contener letras"; } } if (textMessage.getText().toString().isEmpty()) { mensaje += "\n Complete el campo mensaje"; } if (textMessage.getText().toString().length() > 160) { mensaje += "\n El mensaje no puede contener ms de 160 caracteres"; } if (mensaje.isEmpty()) { return true; } else { Alert alert = new Alert(AlertType.WARNING); alert.setContentText(mensaje); alert.showAndWait(); return false; } }