Example usage for javafx.scene.control ButtonType YES

List of usage examples for javafx.scene.control ButtonType YES

Introduction

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

Prototype

ButtonType YES

To view the source code for javafx.scene.control ButtonType YES.

Click Source Link

Document

A pre-defined ButtonType that displays "Yes" and has a ButtonData of ButtonData#YES .

Usage

From source file:de._692b8c32.cdlauncher.MainController.java

public MainController(Application application, Preferences preferences) {
    this.application = application;
    this.preferences = preferences;

    if (preferences.get("basedir", null) == null) {
        while (new OptionsController(application, preferences).selectDirectory() == null) {
            new Alert(Alert.AlertType.ERROR,
                    "The launcher needs a directory to store temporary files. Press cancel if you want to close the application.",
                    ButtonType.CANCEL, ButtonType.PREVIOUS).showAndWait().ifPresent(button -> {
                        if (button == ButtonType.CANCEL) {
                            throw new RuntimeException("User requested abort.");
                        }/*from  w w  w . j a va2  s .  c  o  m*/
                    });
        }

        new Alert(Alert.AlertType.INFORMATION,
                "Do you want to use a prebuilt version of OpenRA? This is recommended unless you are an OpenRA developer.",
                ButtonType.NO, ButtonType.YES).showAndWait().ifPresent(button -> {
                    if (button == ButtonType.YES) {
                        preferences.putBoolean("buildFromSources", false);
                    }
                    if (button == ButtonType.NO) {
                        preferences.putBoolean("buildFromSources", true);
                    }
                });

        if (System.getProperty("os.name").toLowerCase().contains("win")) {
            preferences.put("commandMono", "");
            preferences.put("commandMake", "");
        }
    }
}

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@FXML
private void onAbrirActionEvent(ActionEvent event) {
    File csvFile = null;/*  w  w w  . j  av a2s  . co m*/
    try {
        if (!saved) {
            Alert a = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
            a.setHeaderText("Deseja descartar as alteraes??");
            a.initOwner(root.getScene().getWindow());
            Optional<ButtonType> result = a.showAndWait();
            if (result.get() != ButtonType.YES) {
                return;
            }
        }
        csvFile = openFileChooser();
        if (csvFile == null || !csvFile.exists()) {
            throw new FileNotFoundException("O arquivo selecionado no existe!");
        }
        ObservableList<CSVRow> rows = readFile(csvFile);
        if (rows == null || rows.isEmpty()) {
            throw new FilerException("O arquivo selecionado est vazio!");
        }
        updateTable(rows);
        this.file = csvFile;
        setSaved();
    } catch (Exception ex) {
        ex.printStackTrace();
        Alert d = new Alert(Alert.AlertType.ERROR);
        d.setHeaderText(
                "Ooops, no foi possvel abrir o arquivo " + (csvFile != null ? csvFile.getName() : "."));
        d.setContentText(ex.getMessage());
        d.setTitle("Erro");
        d.initOwner(root.getScene().getWindow());
        d.show();
    }
}

From source file:com.exalttech.trex.util.Util.java

/**
 * Confirm deletion message window/*from w w w. ja  va 2  s  .  c om*/
 *
 * @param deleteMsg
 * @return
 */
public static boolean isConfirmed(String deleteMsg) {
    Alert confirmMsgBox = Util.getAlert(Alert.AlertType.CONFIRMATION);
    confirmMsgBox.getButtonTypes().clear();
    confirmMsgBox.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);
    confirmMsgBox.setContentText(deleteMsg);
    Optional<ButtonType> result = confirmMsgBox.showAndWait();
    return result.get() == ButtonType.YES;
}

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@FXML
private void onSairActionEvent(ActionEvent event) {
    if (saved) {//from   www .jav a 2s. co m
        sair();
    } else {
        Alert a = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
        a.setHeaderText("Deseja sair sem salvar?");
        a.initOwner(root.getScene().getWindow());
        Optional<ButtonType> result = a.showAndWait();
        if (result.get() == ButtonType.YES) {
            sair();
        }
    }
}

From source file:org.beryx.viewreka.fxapp.Viewreka.java

private boolean tryClose(Tab tab) {
    if (project == null)
        return false;
    CodeTabData tabData = getData(tab);//ww  w .java  2  s .co  m
    if (tabData.isDirty()) {
        ButtonType answer = Dialogs.confirmYesNoCancel("Close File", "This file has unsaved changes",
                "Save changes before closing the file?");
        if (answer == ButtonType.YES) {
            saveFile();
        } else if (answer == ButtonType.CANCEL) {
            return false;
        }
    }
    String filePath = tabData.getFilePath();
    ProjectSettings projectSettings = project.getProjectSettingsManager().getSettings();
    List<String> openFiles = getOpenFiles(projectSettings);
    openFiles.remove(filePath);
    return true;
}

From source file:org.beryx.viewreka.fxapp.Viewreka.java

public boolean tryCloseProject() {
    if (hasUnsavedChanges()) {
        ButtonType answer = Dialogs.confirmYesNoCancel("Close Project",
                "One or more files have unsaved changes", "Save changes before closing the project?");
        if (answer == ButtonType.YES) {
            saveAll();// w w  w.j  a v  a  2  s .  c  o  m
        } else if (answer == ButtonType.CANCEL) {
            return false;
        }
    }
    forceCloseProject(true);
    return true;
}

From source file:topt.FXMLDocumentController.java

@FXML
private void handleButtonAddElement(ActionEvent event) {
    try {//w  ww  .  j  a v  a2  s  .  c  o m
        if (elementsCBox.getValue() != null && !elementsCBox.getValue().toString().isEmpty()) {
            int numberOfEl = Integer.parseInt(elementsNr.getText());
            double standardDevDouble = Double.parseDouble(standardDev.getText());
            double expectedValueDouble = Double.parseDouble(expectedValue.getText());

            data.add(data.size(), new RowData(elementsCBox.getValue().toString(), numberOfEl, standardDevDouble,
                    expectedValueDouble));

            addedElementList.setItems(data);
        } else {
            Alert alert = new Alert(Alert.AlertType.ERROR, "Wybierz element", ButtonType.YES);
            alert.showAndWait();
        }
    } catch (NumberFormatException nfe) {
        Alert alert = new Alert(Alert.AlertType.ERROR, "Niepoprawny format danych (liczb)", ButtonType.YES);
        alert.showAndWait();
    }
}

From source file:topt.FXMLDocumentController.java

@FXML
private void handleButtonCompute(ActionEvent event) {
    System.out.println("Compute!");
    double sum = 0;
    double sumInSquare = 0;
    double expectedError = 0;
    for (RowData element : addedElementList.getItems()) {
        sum += element.getExpectedValue() * element.getNrOfElements();
        sumInSquare += Math.pow(element.getStandardDev(), 2) * element.getNrOfElements();
    }/*ww  w  . j av a 2 s .c o m*/

    if (!tfError.getText().isEmpty())
        expectedError = Double.parseDouble(tfError.getText()) / 100;
    else {
        Alert alert = new Alert(Alert.AlertType.ERROR, "Prosz poda warto dopuszczalnegobdu [%]",
                ButtonType.YES);
        alert.showAndWait();
        return;
    }

    double nrOfStDev = computeNrStDev(sum, Math.sqrt(sumInSquare), expectedError);
    double attenuationMax = sum + nrOfStDev * Math.sqrt(sumInSquare);
    double attenuationMin = sum - nrOfStDev * Math.sqrt(sumInSquare);
    attenuationMax = roundResult(attenuationMax);
    attenuationMin = roundResult(attenuationMin);

    result.setText("Zakres tumienia toru optycznego mieci si w zakresie od: " + attenuationMin
            + "[dB] do " + attenuationMax + "[dB]");

}