Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

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

Prototype

int QUESTION_MESSAGE

To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.

Click Source Link

Document

Used for questions.

Usage

From source file:uk.co.markfrimston.tasktree.Main.java

@Override
public boolean confirmMerge() {
    return JOptionPane.showConfirmDialog(this, "Was the merge completed successfully?", "Merge",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION;

}

From source file:edu.ku.brc.specify.ui.AppBase.java

/**
 * //from ww w  .j a va 2s .c  o  m
 */
protected void checkForUpdates() {
    try {
        UpdateDescriptor updateDesc = UpdateChecker.getUpdateDescriptor(
                UIRegistry.getResourceString("UPDATE_PATH"), ApplicationDisplayMode.UNATTENDED);

        UpdateDescriptorEntry entry = updateDesc.getPossibleUpdateEntry();

        if (entry != null) {
            Object[] options = { getResourceString("Specify.INSTALLUPDATE"), //$NON-NLS-1$
                    getResourceString("Specify.SKIP") //$NON-NLS-1$
            };
            int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
                    getLocalizedMessage("Specify.UPDATE_AVAIL", entry.getNewVersion()), //$NON-NLS-1$
                    getResourceString("Specify.UPDATE_AVAIL_TITLE"), //$NON-NLS-1$
                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (userChoice == JOptionPane.YES_OPTION) {
                if (!doExit(false)) {
                    return;
                }

            } else {
                return;
            }
        } else {
            UIRegistry.showLocalizedError("Specify.NO_UPDATE_AVAIL");
            return;
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        UIRegistry.showLocalizedError("Specify.UPDATE_CHK_ERROR");
        return;
    }

    try {
        ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() {
            public void exited(int exitValue) {
                System.err.println("exitValue: " + exitValue);
                //startApp(doConfig);
            }

            public void prepareShutdown() {
                System.err.println("prepareShutdown");

            }
        };
        ApplicationLauncher.launchApplication("100", null, true, callback);

    } catch (Exception ex) {
        System.err.println("EXPCEPTION");
    }
}

From source file:io.heming.accountbook.ui.MainFrame.java

private void deleteRecord() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(MainFrame.this, "", "",
                JOptionPane.ERROR_MESSAGE);
        return;//ww  w . ja  v a 2  s .c o  m
    }
    Record record = model.getRecord(table.convertRowIndexToModel(selectedRow));
    System.out.println(record);
    if (JOptionPane.showConfirmDialog(MainFrame.this,
            String.format("??%d?", record.getId()), "",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
        try {
            recordFacade.delete(record);
            searchRecords();
        } catch (Exception e1) {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(MainFrame.this, e1.getMessage(), "", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java

private void configure() {
    // List all serial port in a drop down list, so a new one can be
    // selected.//ww  w. ja  va  2  s  .  c om
    refreshSerialPortList();
    String selectedPort = (String) JOptionPane.showInputDialog(appWindow,
            resourceBundle.getString("Instruction.Choose_port"), resourceBundle.getString("Title.Settings"),
            JOptionPane.QUESTION_MESSAGE, null, availablePortNames.toArray(), getComPort());

    if (selectedPort != null) {
        setComPort(selectedPort);

        try {
            settingsHelper.saveSettings(localSettings);
        } catch (CouldNotSaveSettingsException e) {
            log.error("Local settings could not be persisted.", e);
        }

        setupSerialPort();
    }
}

From source file:Forms.CreateGearForm.java

private void showLintErrorDialog(GearSpecLintResult result) {
    Object[] options = { "OK" };
    int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel),
            result.getResponseMessage(), "Lint Error", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE,
            null, options, options[0]);//from www. ja  v  a  2 s .  c o m
}

From source file:net.sf.jabref.exporter.SaveDatabaseAction.java

/**
 * Check whether or not the external database has been modified. If so need to alert the user to accept external updates prior to
 * saving the database. This is necessary to avoid overwriting other users work when using a multiuser database file.
 *
 * @return true if the external database file has been modified and the user must choose to accept the changes and false if no modifications
 * were found or there is no requested protection for the database file.
 *//*from  w ww.  j a va 2s  . c o m*/
private boolean checkExternalModification() {
    // Check for external modifications:
    if (panel.isUpdatedExternally()
            || Globals.fileUpdateMonitor.hasBeenModified(panel.getFileMonitorHandle())) {
        String[] opts = new String[] { Localization.lang("Review changes"), Localization.lang("Save"),
                Localization.lang("Cancel") };
        int answer = JOptionPane.showOptionDialog(panel.frame(),
                Localization.lang("File has been updated externally. " + "What do you want to do?"),
                Localization.lang("File updated externally"), JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, opts, opts[0]);

        if (answer == JOptionPane.CANCEL_OPTION) {
            canceled = true;
            return true;
        } else if (answer == JOptionPane.YES_OPTION) {
            canceled = true;

            JabRefExecutorService.INSTANCE.execute((Runnable) () -> {

                if (!FileBasedLock.waitForFileLock(panel.getBibDatabaseContext().getDatabaseFile(), 10)) {
                    // TODO: GUI handling of the situation when the externally modified file keeps being locked.
                    LOGGER.error("File locked, this will be trouble.");
                }

                ChangeScanner scanner = new ChangeScanner(panel.frame(), panel,
                        panel.getBibDatabaseContext().getDatabaseFile());
                JabRefExecutorService.INSTANCE.executeWithLowPriorityInOwnThreadAndWait(scanner);
                if (scanner.changesFound()) {
                    scanner.displayResult((ChangeScanner.DisplayResultCallback) resolved -> {
                        if (resolved) {
                            panel.setUpdatedExternally(false);
                            SwingUtilities.invokeLater(
                                    (Runnable) () -> panel.getSidePaneManager().hide("fileUpdate"));
                        } else {
                            canceled = true;
                        }
                    });
                }
            });

            return true;
        } else { // User indicated to store anyway.
            if (panel.getBibDatabaseContext().getMetaData().isProtected()) {
                JOptionPane.showMessageDialog(frame, Localization
                        .lang("Database is protected. Cannot save until external changes have been reviewed."),
                        Localization.lang("Protected database"), JOptionPane.ERROR_MESSAGE);
                canceled = true;
            } else {
                panel.setUpdatedExternally(false);
                panel.getSidePaneManager().hide("fileUpdate");
            }
        }
    }

    // Return false as either no external database file modifications have been found or overwrite is requested any way
    return false;
}

From source file:com.jvms.i18neditor.editor.Editor.java

public void showDuplicateTranslationDialog(String key) {
    String newKey = "";
    while (newKey != null && newKey.isEmpty()) {
        newKey = Dialogs.showInputDialog(this, MessageBundle.get("dialogs.translation.duplicate.title"),
                MessageBundle.get("dialogs.translation.duplicate.text"), JOptionPane.QUESTION_MESSAGE, key,
                true);// ww w .  j a v  a 2  s.  co m
        if (newKey != null) {
            newKey = newKey.trim();
            if (!ResourceKeys.isValid(newKey)) {
                showError(MessageBundle.get("dialogs.translation.duplicate.error"));
            } else {
                TranslationTreeNode newNode = translationTree.getNodeByKey(newKey);
                TranslationTreeNode oldNode = translationTree.getNodeByKey(key);
                if (newNode != null) {
                    boolean isReplace = newNode.isLeaf() || oldNode.isLeaf();
                    boolean confirm = Dialogs.showConfirmDialog(this,
                            MessageBundle.get("dialogs.translation.conflict.title"),
                            MessageBundle.get(
                                    "dialogs.translation.conflict.text." + (isReplace ? "replace" : "merge")),
                            JOptionPane.WARNING_MESSAGE);
                    if (confirm) {
                        duplicateTranslationKey(key, newKey);
                    }
                } else {
                    duplicateTranslationKey(key, newKey);
                }
            }
        }
    }
}

From source file:Forms.CreateGearForm.java

private void showSaveErrorDialog() {
    Object[] options = { "OK" };
    int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(MasterPanel),
            "There was a problem saving your Gear Spec. Please try again.", "Lint Error", JOptionPane.OK_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
}

From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java

public void reinitializeGroovyConditions() {
    String dialogTitle = "Reinitialize example groovy conditions?";
    String message = "This overwrites all example groovy conditions. Other conditions are not changed!\nReinitialize example groovy conditions right now?";
    int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    // TODO: add "Show in Finder/Explorer" button if running on Mac/Windows
    if (JOptionPane.OK_OPTION != result) {
        return;// w ww .  j  a v  a2s . c o m
    }

    applicationPreferences.installExampleConditions();
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*from w w w.jav a  2 s . c om*/
 * @return
 */
public Action getSelectTankAction() {
    Action ret = actionMap.get(ACTION_SELECT_TANK);
    if (ret == null) {
        ret = new AbstractAction(ACTION_SELECT_TANK) {
            private static final long serialVersionUID = 1L;
            final JComboBox cb = getComboBox();

            @Override
            public void actionPerformed(ActionEvent event) {
                try {
                    int selected = JOptionPane.showConfirmDialog(debuggerFrame, cb,
                            "Enter the base URL to Tank:", JOptionPane.OK_CANCEL_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (selected == JOptionPane.OK_OPTION) {
                        String url = (String) cb.getSelectedItem();
                        if (url != null) {
                            int startInd = url.indexOf('(');
                            int endInd = url.indexOf(')');
                            if (startInd != -1 && endInd != -1) {
                                url = url.substring(startInd + 1, endInd);
                            }
                            url = StringUtils.removeEndIgnoreCase(url, "/");
                            if (!url.startsWith("http")) {
                                url = "http://" + url;
                            }
                            try {
                                new ScriptServiceClient(url).ping();
                                setServiceUrl(url);
                            } catch (Exception e) {
                                showError("Cannot connect to Tank at the url " + url
                                        + ". \nExample: http://tank.mysite.com/");
                            }
                        }
                    }
                } catch (HeadlessException e) {
                    showError("Error opening file: " + e);
                }
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Enter a Tank URL.");
        actionMap.put(ACTION_SELECT_TANK, ret);
    }
    return ret;
}