Example usage for javax.swing JOptionPane showConfirmDialog

List of usage examples for javax.swing JOptionPane showConfirmDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showConfirmDialog.

Prototype

public static int showConfirmDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Brings up a dialog with the options Yes, No and Cancel; with the title, Select an Option.

Usage

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplatePanel.java

public boolean promptSave(boolean force) {
    stopTableEditing();/*from w  w w  .  j  ava2 s . c  om*/
    int option;

    if (force) {
        option = JOptionPane.showConfirmDialog(parent,
                "You must save the code template changes before continuing. Would you like to save now?");
    } else {
        option = JOptionPane.showConfirmDialog(parent, "Would you like to save the code templates?");
    }

    if (option == JOptionPane.YES_OPTION) {
        CodeTemplateLibrarySaveResult updateSummary = doSaveCodeTemplates(false);

        if (updateSummary == null || updateSummary.isOverrideNeeded() || !updateSummary.isLibrariesSuccess()) {
            return false;
        } else {
            for (CodeTemplateUpdateResult result : updateSummary.getCodeTemplateResults().values()) {
                if (!result.isSuccess()) {
                    return false;
                }
            }
        }
    } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION
            || (option == JOptionPane.NO_OPTION && force)) {
        return false;
    }

    return true;
}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private void changeLoadLimit() {
    try {/*from   w  ww . ja v a2  s.c  o m*/
        String input = JOptionPane.showInputDialog("Change the load limit to (0 means unlimited)",
                frame.getLoadLimit());
        if (input == null)
            return;
        frame.setLoadLimit(Integer.valueOf(input));

        FileUtils.writeStringToFile(frame.loadLimitFile, String.valueOf(frame.getLoadLimit()));
    } catch (NumberFormatException e) {
        changeLoadLimit();
    } catch (IOException e) {
        JOptionPane.showConfirmDialog(frame, e);
    }
}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private void changeAutoEvalDistance() {
    try {/*  w  ww  .j  av a  2  s . c  om*/
        String input = JOptionPane.showInputDialog("Change the auto eval distance to ",
                frame.getAutoEvalDistance());
        if (input == null)
            return;
        frame.setAutoEvalDistance(Integer.valueOf(input));
        FileUtils.writeStringToFile(frame.autoEvalDistanceFile, String.valueOf(frame.getAutoEvalDistance()));
    } catch (NumberFormatException e) {
        changeLoadLimit();
    } catch (IOException e) {
        JOptionPane.showConfirmDialog(frame, e);
    }
}

From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java

private boolean checkDirty() {
    if (dirty) {/*  w w  w  . j a v a 2  s.com*/
        switch (JOptionPane.showConfirmDialog(null, "Saves changes?")) {
        case JOptionPane.YES_OPTION:
            controller.setActiveSettings(Settings.of(operations, targets, clients));
            controller.saveActiveSettings();
            dirty = false;
            return true;
        case JOptionPane.NO_OPTION:
            dirty = false;
            return true;
        default:
            return false;
        }
    }
    return true;
}

From source file:com.mirth.connect.client.ui.ChannelPanel.java

private boolean promptSave(boolean force) {
    int option;//w w  w  . ja v a2s .c  o m

    if (force) {
        option = JOptionPane.showConfirmDialog(parent,
                "You must save the channel group changes before continuing. Would you like to save now?");
    } else {
        option = JOptionPane.showConfirmDialog(parent, "Would you like to save the channel groups?");
    }

    if (option == JOptionPane.YES_OPTION) {
        return doSaveGroups(false);
    } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION
            || (option == JOptionPane.NO_OPTION && force)) {
        return false;
    }

    return true;
}

From source file:com.sciaps.view.SpectrumShotPanel.java

private void doDelete() {

    if (tblShots_.getSelectedRowCount() == 0) {
        showErrorDialog("Nothing is selected.");
        return;/*from w  w w.  j  a v  a  2 s.c  o m*/
    }

    int retval = JOptionPane.showConfirmDialog(Constants.MAIN_FRAME, "Delete Selected Row(s)?");
    if (retval != JOptionPane.YES_OPTION) {
        return;
    }

    shotListTableModel_.removeRows(getSelectedRows());
}