Example usage for javafx.scene.control Alert Alert

List of usage examples for javafx.scene.control Alert Alert

Introduction

In this page you can find the example usage for javafx.scene.control Alert Alert.

Prototype

public Alert(@NamedArg("alertType") AlertType alertType) 

Source Link

Document

Creates an alert with the given AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

Usage

From source file:ExcelFx.InitalDataController.java

@FXML
protected void okButton(ActionEvent event) throws IOException {
    DropShadow ds = new DropShadow();
    ds.setColor(Color.RED);/* w  ww .  j  a v  a  2 s . c o  m*/

    String err = "";
    if (initalField.getText().length() == 0) {
        err += "  ";
        initalField.setEffect(ds);

    }
    if (initalPage.getText().length() == 0) {
        err += " ?  excel  ";
        initalPage.setEffect(ds);

    }
    if (yStart.getText().length() == 0) {
        err += "   ? ";
        yStart.setEffect(ds);

    }
    if (yEnd.getText().length() == 0) {
        err += "   ? ";
        yEnd.setEffect(ds);

    }

    if (err.length() != 0) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("");
        alert.setHeaderText("?  ?");
        alert.setContentText(err);
        alert.showAndWait();

    } else {
        Stage stage = (Stage) gridPane.getScene().getWindow();
        stage.close();
        this.codes.setPatch(this.initalField.getText());
        this.codes.setPage((this.initalPage.getText()).trim().toLowerCase());
        this.codes.setYStart(this.yStart.getText().trim().toLowerCase());
        this.codes.setYEnd(this.yEnd.getText().trim().toLowerCase());
        this.codes.jsonCreate("inital.json");

    }
    this.gridPane.setUserData(this.codes);

}

From source file:net.thirdy.blackmarket.controls.Dialogs.java

public static void showAbout() {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setGraphic(new Region());
    alert.setTitle("Blackmarket " + BlackmarketApplication.VERSION);
    alert.setContentText("");
    alert.setHeaderText("");

    TextArea textArea = new TextArea("Copyright 2015 Vicente de Rivera III" + "\r\n"
            + "\r\n http://thirdy.github.io/blackmarket" + "\r\n"
            + "\r\n This program is free software; you can redistribute it and/or"
            + "\r\n modify it under the terms of the GNU General Public License"
            + "\r\n as published by the Free Software Foundation; either version 2"
            + "\r\n of the License, or (at your option) any later version." + "\r\n"
            + "\r\n This program is distributed in the hope that it will be useful,"
            + "\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of"
            + "\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
            + "\r\n GNU General Public License for more details." + "\r\n"
            + "\r\n You should have received a copy of the GNU General Public License"
            + "\r\n along with this program; if not, write to the Free Software"
            + "\r\n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA." + "\r\n");
    textArea.setEditable(false);//w ww. j a  va2 s.  c o m
    textArea.setWrapText(true);

    Hyperlink website = new Hyperlink("Visit Blackmarket Homepage");
    website.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://thirdy.github.io/blackmarket/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    Hyperlink exwebsite = new Hyperlink("Visit Exile Tools Homepage");
    exwebsite.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://exiletools.com/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    VBox content = new VBox(new ImageView(new Image("/images/blackmarket-logo.png")), new Label(
            "Blackmarket is fan-made software for Path of Exile but is not affiliated with Grinding Gear Games in any way."),
            new Label("A few tips:"), new Label("CTRL + Space - hot key to slide the search control pane"),
            new Label("CTRL + Enter - hot key to run the search"),
            new Label("Advance mode grants you power overwhelming of Elastic Search"),
            new Label("For more information and updates,"), website,
            new Label("Blackmarket uses Exile Tools Shop Indexer Elastic Search API:"), exwebsite,
            new Label("Comics by /u/gallio"),
            new Label("Blackmarket is 100% Free and Open Source Software under GPLv2:"), textArea);
    content.setSpacing(8);
    alert.getDialogPane().setContent(content);
    alert.showAndWait();

}

From source file:com.properned.application.LocaleListCell.java

private MenuItem getDeleteMenu(Locale locale) {
    MenuItem deleteMenu = new MenuItem(MessageReader.getInstance().getMessage("action.deleteMessageKey"));
    deleteMenu.setOnAction(new EventHandler<ActionEvent>() {
        @Override//from  w  ww .  j  a  va2 s.  c om
        public void handle(ActionEvent event) {
            logger.info("Clic on delete button for locale '" + locale.toString() + "'");

            String fileName = properties.getMapPropertiesFileByLocale().get(locale).getAbsolutePath();

            Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.title"));
            alert.setHeaderText(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.header"));
            alert.setContentText(
                    MessageReader.getInstance().getMessage("manageLocale.confirmDelete.content", fileName));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.isPresent() && result.get() == ButtonType.OK) {
                logger.info("User say OK to the confirm");
                properties.deleteLocale(locale);

                // Reload list
                controller.initializeList();
            }

        }
    });

    if (properties.getMapPropertiesByLocale().keySet().size() <= 1) {
        // We can delete only if there is more than the current locale
        deleteMenu.setDisable(true);
    }

    return deleteMenu;
}

From source file:de.fraunhofer.iosb.ilt.stc.FXMLController.java

@FXML
private void actionSave(ActionEvent event) {
    JsonElement json = configEditor.getConfig();
    String config = new GsonBuilder().setPrettyPrinting().create().toJson(json);
    fileChooser.setTitle("Save Config");
    File file = fileChooser.showSaveDialog(paneConfig.getScene().getWindow());

    try {/*from   w ww .j  av a2 s.c  om*/
        FileUtils.writeStringToFile(file, config, "UTF-8");
    } catch (IOException ex) {
        LOGGER.error("Failed to write file.", ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("failed to write file");
        alert.setContentText(ex.getLocalizedMessage());
        alert.showAndWait();
    }
}

From source file:cz.lbenda.rcp.DialogHelper.java

/** Ask user if file can be overwrite if file exist */
@SuppressWarnings("unused")
public boolean canBeOverwriteDialog(File file) {
    if (file == null) {
        return false;
    }//from w w w.  java 2s  .  c  o m
    if (!file.exists()) {
        return true;
    }
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(msgCanOverwriteTitle);
    alert.setContentText(String.format(msgCanOverwriteContent, file.getName()));
    Optional<ButtonType> result = alert.showAndWait();
    return (result.isPresent()) && (result.get() == ButtonType.OK);
}

From source file:account.management.controller.EditLocationController.java

@FXML
private void onUpdateButtonClick(ActionEvent event) {
    try {/*www  .  j a  v  a 2  s.  c om*/

        int id = this.location_select.getSelectionModel().getSelectedItem().getId();
        String name = this.name_input.getText();
        String details = this.details_input.getText();

        JSONArray response = Unirest.post(MetaData.baseUrl + "edit/location").queryString("id", id)
                .queryString("name", name).queryString("details", details).asJson().getBody().getArray();
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setHeaderText(null);
        alert.setContentText("Location has been updated successfully!");
        alert.setGraphic(new ImageView(new Image("resources/success.jpg")));
        alert.showAndWait();
        //this.update_button.getScene().getWindow().hide();

    } catch (Exception 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.hs.mannheim.modUro.controller.diagram.SimulationDiagramController.java

public void init(Simulation simulation) {
    this.simulation = simulation;
    this.simulationDiagram = new SimulationDiagram(simulation);

    if (leftLastSelectedIndex == null || rightLastSelectedIndex == null) {
        initializeChoiceboxContent();//w  w  w  . jav  a  2 s .c o m
    } else {
        if (simulationContainsMetricType()) {
            setChoiceBoxContent();
            setLeftChartContent(leftLastSelectedIndex);
            setRightChartContent(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(newValue.intValue());
            leftLastSelectedIndex = newValue.intValue();
            leftLastSelectedMetrictypename = choiceBoxMetrictypeNames().get(leftLastSelectedIndex);

        }
    });

    rightMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            setRightChartContent(newValue.intValue());
            rightLastSelectedIndex = newValue.intValue();
            rightLastSelectedMetrictypename = choiceBoxMetrictypeNames().get(rightLastSelectedIndex);
        }
    });
}

From source file:dev.archiecortez.jfacelog.employeemanager.EmployeeManagerPresenter.java

@FXML
public void newPass() throws IOException {
    NewPassDialog newPassDialog = new NewPassDialog();
    Optional<Pair<String, String>> rslt = newPassDialog.showAndWait();
    try {//ww w  . j  av  a2  s. c  om
        if (rslt.isPresent()) {
            DTREmployee emp = (DTREmployee) employeesListView.getSelectionModel().getSelectedItem();
            emp.changePassword(rslt.get().getKey(), rslt.get().getValue());
            employeeDTO.updateEmployee(emp);
        }
    } catch (Exception e) {
        Alert a = new Alert(Alert.AlertType.ERROR);
        a.setTitle("Error setting password.");
        a.setContentText(e.getMessage());
        a.showAndWait();
    }
}

From source file:jasperreports.FXMLDocumentController.java

@FXML
public void handleButtonAction(ActionEvent event) {

    Button b = (Button) event.getSource();
    if (destination.getText().length() > 0) {
        String destinationFileName = destination.getText();

        switch (b.getId()) {
        case "toPDF1":
            Generowanieraportow.generowanieraportu1pdf(destinationFileName);
            break;
        case "toHTML1":
            Generowanieraportow.generowanieraportu1html(destinationFileName);
            break;
        case "toPDF2":
            Generowanieraportow.generowanieraportu2pdf(destinationFileName);
            break;
        case "toHTML2":
            Generowanieraportow.generowanieraportu2html(destinationFileName);
            break;
        case "toPDF3":
            Generowanieraportow.generowanieraportu3pdf(destinationFileName);
            break;
        case "toHTML3":
            Generowanieraportow.generowanieraportu3html(destinationFileName);
            break;
        case "toPDF4":
            Generowanieraportow.generowanieraportu4pdf(destinationFileName);
            break;
        case "toHTML4":
            Generowanieraportow.generowanieraportu4html(destinationFileName);
            break;
        case "toPDF5":
            Generowanieraportow.generowanieraportu5pdf(destinationFileName);
            break;
        case "toHTML5":
            Generowanieraportow.generowanieraportu5html(destinationFileName);
            break;
        case "toPDF6":
            Generowanieraportow.generowanieraportu6pdf(destinationFileName);
            break;
        case "toHTML6":
            Generowanieraportow.generowanieraportu6html(destinationFileName);
            break;
        }/*from w ww  .  j ava 2s .com*/

    } else {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Bd");
        alert.setHeaderText(null);
        alert.setContentText("Prosz wybra folder docelowy!");
        alert.showAndWait();
    }

}

From source file:sendsms.FXMLDocumentController.java

private ChangeListener onValueComboBoxChange() {
    return new ChangeListener<String>() {
        @Override//from  w w w  . j a  va2 s  .com
        public void changed(ObservableValue ov, String t, String newValue) {
            if (textOrden.getText().equals("")) {
                Alert alert = new Alert(AlertType.WARNING);
                alert.setHeaderText("Por favor complete el campo orden");
                alert.showAndWait();
            } else if (newValue.equals("Corregir direccin")) {
                setMessage(textOrden.getText() + DIRECCION_CONTENT);
            } else if (newValue.equals("Error con tarjeta")) {
                setMessage(textOrden.getText() + TARJETA_CONTENT);
            } else if (newValue.equals("Esperamos boleta")) {
                setMessage(textOrden.getText() + ESPERA_CONTENT);
            } else if (newValue.equals("Pasar")) {
                setMessage(textOrden.getText() + PASAR_CONTENT);
            } else if (newValue.equals("Conflicto en entrega")) {
                setMessage(textOrden.getText() + LLAMA_CONTENT);
            } else if (newValue.equals("Montos mayores")) {
                setMessage(textOrden.getText() + MONTOS_CONTENT);
            }
        }
    };
}