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:com.sshtools.sshvnc.SshVncSessionPanel.java

/**
 *
 *
 * @return//from w w  w . j a v  a 2 s  . c  o m
 */
public boolean canClose() {
    if (isConnected()) {
        if (JOptionPane.showConfirmDialog(this, "Close the current session and exit?", "Exit Application",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
            return false;
        }
    }

    return true;
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

/**
 * /*from   ww  w.  j  a  v a 2 s . c  o m*/
 */
protected void checkForChanges() {
    if (fieldHasChanged) {
        Object[] options = { getResourceString("SAVE"), //$NON-NLS-1$ 
                getResourceString("DISCARD") }; //$NON-NLS-1$
        int retVal = JOptionPane.showOptionDialog(null, getResourceString("FFE_SAVE_CHG"), //$NON-NLS-1$
                getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, //$NON-NLS-1$
                JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (retVal == JOptionPane.YES_OPTION) {
            fieldsPanel.getEditBtn().doClick();
        }
    }
}

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

private void newConfigFile() {
    String fileName = JOptionPane.showInputDialog(null, "Please enter a name for the new configuration:",
            "Configuration Name", JOptionPane.QUESTION_MESSAGE);
    if (fileName == null) {
        return;/*from  w  w  w .  ja  v a 2 s. c  o  m*/
    }

    if (!isExtension(fileName, "xml")) {
        fileName += ".xml";
    }
    checkState(isNotBlank(fileName), "File name must not be empty.");
    checkState(!configFiles.contains(fileName), "The file '" + fileName + "' already exists.");

    configFiles.add(fileName);

    controller.setActiveSettingsFile(fileName);
    cboConfigurationFile.setSelectedItem(fileName);
}

From source file:org.syncany.plugins.php.PhpTransferManager.java

@SuppressWarnings("deprecation")
private CloseableHttpClient getHttpClient() {
    try {/*from   w w  w .j  av a  2s .  co m*/
        @SuppressWarnings("deprecation")
        SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
            @Override
            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                if (lastSite != null && !lastSite.equals("")) {
                    Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
                    int prevr = prefs.getInt(lastSite, -1);
                    if (prevr == -1) {
                        int r = JOptionPane.showConfirmDialog(null,
                                lastSite + "'s SSL certificate is not trusted, do you want to accept it?",
                                "Accept SSL Certificate?", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE);
                        logger.warning(lastSite + " not trusted, user answered " + r);
                        prevr = r;
                        prefs.putInt(lastSite, r);
                    }
                    logger.warning(lastSite + " not trusted, registered user answer: " + prevr);
                    if (prevr == 0) {
                        return true;
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        });
        @SuppressWarnings("deprecation")
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("https", 443, sf));
        @SuppressWarnings("deprecation")
        ClientConnectionManager ccm = new ThreadSafeClientConnManager(registry);
        return new DefaultHttpClient(ccm);
    } catch (Exception e) {
        return new DefaultHttpClient();
    }
}

From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java

public static boolean createVOMSLOCATIONDialog() {
    boolean isSuccessful = false;
    VOMSLocationPanel vomsPanel = new VOMSLocationPanel();

    int result = JOptionPane.showConfirmDialog(null, vomsPanel, "VOMS Location", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, new ResourceIcon(vomsPanel.getClass(), ConfigHelper.ICON));
    if (result == JOptionPane.OK_OPTION) {
        if (vomsPanel.getVOMSLocation() != null && !vomsPanel.getVOMSLocation().equals("")) {
            vomslocation = vomsPanel.getVOMSLocation();
            refreshVOMSConfig();//from w w  w. j  a va  2  s .c  om
            PreferencesStore.put(SshTerminalPanel.PREF_VOMS_LOCATION, vomslocation);
        }
    }

    return isSuccessful;
}

From source file:edu.umass.cs.gnsserver.installer.EC2Runner.java

private static boolean showDialog(String message, final long timeout) {
    try {//from   ww  w. j  a  v  a  2s  .  c om
        int dialog = JOptionPane.YES_NO_OPTION;
        JOptionPane optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE,
                JOptionPane.YES_NO_OPTION);
        final JDialog dlg = optionPane.createDialog("Error");
        new Thread(new Runnable() {
            @Override
            public void run() {
                {
                    ThreadUtils.sleep(timeout);
                    dlg.dispose();
                }
            }
        }).start();
        dlg.setVisible(true);
        int value = ((Integer) optionPane.getValue()).intValue();
        if (value == JOptionPane.YES_OPTION) {
            return true;
        } else {
            return false;
        }
    } catch (RuntimeException e) {
        return true;
    }
}

From source file:com.jug.MotherMachine.java

/**
 *
 * @param guiFrame//from www. j av  a  2s. c o m
 *            parent frame
 * @param path
 *            path to be suggested to open
 * @return
 */
private File showStartupDialog(final JFrame guiFrame, final String path) {

    final String parentFolder = path.substring(0, path.lastIndexOf(File.separatorChar));

    int decision = 0;
    if (path.equals(System.getProperty("user.home"))) {
        decision = JOptionPane.NO_OPTION;
    } else {
        final String message = "Should the MotherMachine be opened with the data found in:\n" + path
                + "\n\nIn case you want to choose a folder please select 'No'...";
        final String title = "MotherMachine Start Dialog";
        decision = JOptionPane.showConfirmDialog(guiFrame, message, title, JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
    }
    if (decision == JOptionPane.YES_OPTION) {
        return new File(path);
    } else {
        return showFolderChooser(guiFrame, parentFolder);
    }
}

From source file:com.frostwire.gui.library.LibraryFilesTableMediator.java

/**
 * Override the default removal so we can actually stop sharing
 * and delete the file.//from  w ww . j  a  v  a  2s. c o  m
 * Deletes the selected rows in the table.
 * CAUTION: THIS WILL DELETE THE FILE FROM THE DISK.
 */
public void removeSelection() {
    int[] rows = TABLE.getSelectedRows();
    if (rows.length == 0)
        return;

    if (TABLE.isEditing()) {
        TableCellEditor editor = TABLE.getCellEditor();
        editor.cancelCellEditing();
    }

    List<File> files = new ArrayList<File>(rows.length);

    // sort row indices and go backwards so list indices don't change when
    // removing the files from the model list
    Arrays.sort(rows);
    for (int i = rows.length - 1; i >= 0; i--) {
        File file = DATA_MODEL.getFile(rows[i]);
        files.add(file);
    }

    CheckBoxListPanel<File> listPanel = new CheckBoxListPanel<File>(files, new FileTextProvider(), true);
    listPanel.getList().setVisibleRowCount(4);

    // display list of files that should be deleted
    Object[] message = new Object[] { new MultiLineLabel(I18n.tr(
            "Are you sure you want to delete the selected file(s), thus removing it from your computer?"), 400),
            Box.createVerticalStrut(ButtonRow.BUTTON_SEP), listPanel,
            Box.createVerticalStrut(ButtonRow.BUTTON_SEP) };

    // get platform dependent options which are displayed as buttons in the dialog
    Object[] removeOptions = createRemoveOptions();

    int option = JOptionPane.showOptionDialog(MessageService.getParentComponent(), message, I18n.tr("Message"),
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, removeOptions,
            removeOptions[0] /* default option */);

    if (option == removeOptions.length - 1 /* "cancel" option index */
            || option == JOptionPane.CLOSED_OPTION) {
        return;
    }

    // remove still selected files
    List<File> selected = listPanel.getSelectedElements();
    List<String> undeletedFileNames = new ArrayList<String>();

    for (File file : selected) {
        // stop seeding if seeding
        BittorrentDownload dm = null;
        if ((dm = TorrentUtil.getDownloadManager(file)) != null) {
            dm.setDeleteDataWhenRemove(false);
            dm.setDeleteTorrentWhenRemove(false);
            BTDownloadMediator.instance().remove(dm);
        }

        // close media player if still playing
        if (MediaPlayer.instance().isThisBeingPlayed(file)) {
            MediaPlayer.instance().stop();
            MPlayerMediator.instance().showPlayerWindow(false);
        }

        // removeOptions > 2 => OS offers trash options
        boolean removed = FileUtils.delete(file,
                removeOptions.length > 2 && option == 0 /* "move to trash" option index */);
        if (removed) {

            DATA_MODEL.remove(DATA_MODEL.getRow(file));
        } else {
            undeletedFileNames.add(getCompleteFileName(file));
        }
    }

    clearSelection();

    if (undeletedFileNames.isEmpty()) {
        return;
    }

    // display list of files that could not be deleted
    message = new Object[] { new MultiLineLabel(I18n.tr(
            "The following files could not be deleted. They may be in use by another application or are currently being downloaded to."),
            400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP),
            new JScrollPane(createFileList(undeletedFileNames)) };

    JOptionPane.showMessageDialog(MessageService.getParentComponent(), message, I18n.tr("Error"),
            JOptionPane.ERROR_MESSAGE);

    super.removeSelection();
}

From source file:com.holycityaudio.SpinCAD.SpinCADFile.java

public void fileSaveHex(SpinCADBank bank) {
    // Create a file chooser
    String savedPath = prefs.get("MRUHexFolder", "");

    final JFileChooser fc = new JFileChooser(savedPath);
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Hex Files", "hex");
    fc.setFileFilter(filter);//  www. j  a v  a2 s  . c  om
    fc.showSaveDialog(new JFrame());
    File fileToBeSaved = fc.getSelectedFile();

    if (!fc.getSelectedFile().getAbsolutePath().endsWith(".hex")) {
        fileToBeSaved = new File(fc.getSelectedFile() + ".hex");
    }
    int n = JOptionPane.YES_OPTION;
    if (fileToBeSaved.exists()) {
        JFrame frame1 = new JFrame();
        n = JOptionPane.showConfirmDialog(frame1, "Would you like to overwrite it?", "File already exists!",
                JOptionPane.YES_NO_OPTION);
    }
    if (n == JOptionPane.YES_OPTION) {
        String filePath;
        try {
            filePath = fileToBeSaved.getPath();
            fileToBeSaved.delete();
        } finally {
        }
        for (int i = 0; i < 8; i++) {
            try {
                if (bank.patch[i].isHexFile) {
                    fileSaveHex(i, bank.patch[i].hexFile, filePath);
                } else {
                    fileSaveHex(i, bank.patch[i].patchModel.getRenderBlock().generateHex(), filePath);
                }
            } catch (IOException e) {
                JOptionPane.showOptionDialog(null, "File save error!", "Error", JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, null, null);

                e.printStackTrace();
            }
        }
        saveMRUHexFolder(filePath);
    }
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * @return Return true if there is a small number of labels or whether the user wishes to continue.
 *//*  w ww .j av  a2s  .  c  o  m*/
protected boolean checkForALotOfLabels(final RecordSetIFace recordSet) {
    //
    if (recordSet.getNumItems() > 200) // XXX Pref
    {
        Object[] options = { getResourceString("Create_New_Report"), getResourceString("CANCEL") };
        int n = JOptionPane.showOptionDialog(UIRegistry.get(UIRegistry.FRAME),
                String.format(getResourceString("LotsOfLabels"), new Object[] { (recordSet.getNumItems()) }),
                getResourceString("LotsOfLabelsTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
                null, //don't use a custom Icon
                options, //the titles of buttons
                options[0]); //default button title
        if (n == 1) {
            return false;
        }
    }
    return true;
}