Example usage for javax.swing JOptionPane YES_NO_OPTION

List of usage examples for javax.swing JOptionPane YES_NO_OPTION

Introduction

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

Prototype

int YES_NO_OPTION

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

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:de.lazyzero.kkMulticopterFlashTool.KKMulticopterFlashTool.java

public boolean restart() {
    int response = JOptionPane.showConfirmDialog(mainframe, _("restart.dialog"), _("restart.title"),
            JOptionPane.YES_NO_OPTION);
    if (response == 0)
        return true;
    return false;
}

From source file:ca.osmcanada.osvuploadr.JPMain.java

private void jbAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAddActionPerformed
    try {//from w w  w. ja va  2s.  c om
        JFileChooser fc = new JFileChooser();
        if (!last_dir.isEmpty()) {
            fc.setCurrentDirectory(new java.io.File(last_dir)); // start at application current directory
        }
        fc.setMultiSelectionEnabled(true);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fc.showSaveDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFiles().length == 1) {
                int response = JOptionPane.showConfirmDialog(null,
                        new String(r.getString("immediate_sub_folders").getBytes(), "UTF-8"),
                        new String(r.getString("add_subfolders").getBytes(), "UTF-8"),
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (response == JOptionPane.NO_OPTION) {
                    File folder = fc.getSelectedFile();
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                } else if (response == JOptionPane.YES_OPTION) {
                    //Get a list of subdirectories
                    String[] subDirs = fc.getSelectedFile().list(new FilenameFilter() {
                        @Override
                        public boolean accept(File current, String name) {
                            return new File(current, name).isDirectory();
                        }
                    });

                    for (String subDir : subDirs) {
                        listDir.add(new File(fc.getSelectedFile() + "/" + subDir).getPath());
                    }
                }
            } else if (fc.getSelectedFiles().length > 1) {
                File[] folders = fc.getSelectedFiles();
                for (File folder : folders) {
                    listDir.add(folder.getPath());
                    last_dir = folder.getPath();
                }
            }

        }
    } catch (UnsupportedEncodingException ex) {
    }
}

From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java

private void changeEditable(boolean isLocked, boolean override) {

    if (isLocked) {
        editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED));
        editingLocked.setForeground(Color.BLACK);
        editingLocked.setText(EDITABLE_LOCKED);
        traitsEditable = false;//from   ww w .  j a va2 s  . c  om
    } else {
        TrialManagerPreferences prefs = TrialManagerPreferences.getInstance();

        if (!override && prefs.getShowEditTraitWarning()) {

            JPanel dialogPanel = new JPanel(new BorderLayout());
            JLabel dialogLabel = new JLabel(
                    "<html>Editing <b><i>Traits</i></b> may adversely affect the <b><i>Trials</i></b> using them.");
            JCheckBox checkBox = new JCheckBox("Don't show me this again.", false);
            dialogPanel.add(dialogLabel, BorderLayout.CENTER);
            dialogPanel.add(checkBox, BorderLayout.SOUTH);

            if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, dialogPanel,
                    "Allow Trait Editing?", JOptionPane.YES_NO_OPTION)) {
                editingLocked.setIcon(KDClientUtils.getIcon(ImageId.UNLOCKED));
                editingLocked.setForeground(Color.RED);
                editingLocked.setText(EDITABLE_UNLOCKED);
                traitsEditable = true;
            }

            if (checkBox.isSelected()) {
                prefs.setShowEditTraitWarning(false);
            }
        } else {
            editingLocked.setIcon(KDClientUtils.getIcon(ImageId.UNLOCKED));
            editingLocked.setForeground(Color.RED);
            editingLocked.setText(EDITABLE_UNLOCKED);
            traitsEditable = true;
        }
    }
}

From source file:com.claim.ui.UiReportType5.java

private void btn197GenReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn197GenReportActionPerformed
    final DialogWaitProcess wait = new DialogWaitProcess();

    try {//from   w  w w. j  a  va  2s . c  o  m
        if (comboYearType5.getSelectedIndex() != 0) {
            if (comboNumType5.getSelectedIndex() != 0) {
                if (radioDetailType5.isSelected() || radioSumType5.isSelected()) {
                    if (radioTopic197.isSelected() || radioTopicHighcost.isSelected()) {
                        if (radioAllHospitalType5.isSelected() || radioSingleHospitalType5.isSelected()) {
                            if (radioAllHospitalType5.isSelected()
                                    || radioSingleHospitalType5.isSelected() && listSelectHospital.size() > 0) {

                                if (!txtPathFileType5.getText().isEmpty()) {
                                    int selectOption = JOptionPane.showConfirmDialog(null,
                                            ConstantMessage.MSG_REPORT_CONFIRM,
                                            ConstantMessage.MSG_REPORT_INFOMATION, JOptionPane.YES_NO_OPTION);
                                    if (selectOption == JOptionPane.YES_OPTION) {
                                        wait.setVisible(true);

                                        Thread thread = new Thread(new Runnable() {
                                            @Override
                                            public void run() {
                                                ProgrameStatus programeStatus = new ProgrameStatus();
                                                try {
                                                    wait.setTitle(ConstantMessage.MSG_PROGRAME_PROCESSSING);
                                                    if (radioDetailType5.isSelected()) { // 
                                                        // status = individualController.op_individual_detail_MutiSheet(setInputFormReport());
                                                        programeStatus = type5Controller
                                                                .type5_detail(setInputFormReport());

                                                        if (programeStatus.getProcessStatus()) {
                                                            JOptionPane.showMessageDialog(UiReportType5.this,
                                                                    programeStatus.getMessage(),
                                                                    programeStatus.getTitle(),
                                                                    JOptionPane.INFORMATION_MESSAGE);
                                                            baseFunction.openDirectoryAutomatic(
                                                                    setInputFormReport().getPathFile());
                                                        } else {
                                                            JOptionPane.showMessageDialog(UiReportType5.this,
                                                                    programeStatus.getMessage(),
                                                                    programeStatus.getTitle(),
                                                                    JOptionPane.ERROR_MESSAGE);
                                                        }
                                                    } else { // 
                                                        programeStatus = type5Controller
                                                                .type5_summary(setInputFormReport());
                                                        if (programeStatus.getProcessStatus()) {
                                                            JOptionPane.showMessageDialog(UiReportType5.this,
                                                                    programeStatus.getMessage(),
                                                                    programeStatus.getTitle(),
                                                                    JOptionPane.INFORMATION_MESSAGE);
                                                            baseFunction.openDirectoryAutomatic(
                                                                    setInputFormReport().getPathFile());
                                                        } else {
                                                            JOptionPane.showMessageDialog(UiReportType5.this,
                                                                    programeStatus.getMessage(),
                                                                    programeStatus.getTitle(),
                                                                    JOptionPane.ERROR_MESSAGE);
                                                        }
                                                    }
                                                    wait.setVisible(false);
                                                } catch (Exception e) {
                                                    e.printStackTrace();
                                                }
                                                /*
                                                 * 17-08-2015
                                                 */
                                                /*try {
                                                 new LogAppController().createLog("??", "?? type5 ? ?? ", NetUtils.getIpAddress(), 1);
                                                 } catch (UnknownHostException ex) {
                                                 Logger.getLogger(UiMainClaim.class.getName()).log(Level.SEVERE, null, ex);
                                                 }*/
                                            }
                                        });
                                        thread.start();
                                    }

                                } else {
                                    JOptionPane.showMessageDialog(this,
                                            ConstantMessage.MSG_FILE_LOCATION_PLEASE,
                                            ConstantMessage.MSG_FILE_LOCATION, JOptionPane.ERROR_MESSAGE);
                                }
                            } else {
                                JOptionPane.showMessageDialog(this, ConstantMessage.MSG_HOSPITAL_SELECT_PLEASE,
                                        ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
                            }
                        } else {
                            JOptionPane.showMessageDialog(this, ConstantMessage.MSG_HOSPITAL_ATTRIBUTE,
                                    ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
                        }
                    } else {
                        JOptionPane.showMessageDialog(this, ConstantMessage.MSG_197_HIGTHCOST,
                                ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
                    }
                } else {
                    JOptionPane.showMessageDialog(this, ConstantMessage.MSG_REPOTR_FORMAT,
                            ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(this, ConstantMessage.MSG_SELECT_NO,
                        ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this, ConstantMessage.MSG_SELECT_DATE_PLEASE,
                    ConstantMessage.MSG_SELECT_DATA, JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.jug.MoMA.java

/**
 *
 * @param guiFrame//w ww .  j  a va2s  . com
 *            parent frame
 * @param datapath
 *            path to be suggested to open
 * @return
 */
private File showStartupDialog(final JFrame guiFrame, final String datapath) {

    File file = null;
    final String parentFolder = datapath.substring(0, datapath.lastIndexOf(File.separatorChar));

    // DATA TO BE LOADED --- DATA TO BE LOADED --- DATA TO BE LOADED --- DATA TO BE LOADED

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

    // CLASSIFIER TO BE LOADED --- CLASSIFIER TO BE LOADED --- CLASSIFIER TO BE LOADED

    //      final String message = "Should this classifier be used:\n" + SEGMENTATION_CLASSIFIER_MODEL_FILE + "\n\nIn case you want to choose a different one, please select 'No'...";
    //      final String title = "MotherMachine Classifier Selection";
    //      decision = JOptionPane.showConfirmDialog( guiFrame, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
    //      if ( decision == JOptionPane.YES_OPTION ) {
    //         GrowthLineSegmentationMagic.setClassifier( SEGMENTATION_CLASSIFIER_MODEL_FILE, "" );
    //      } else {
    //         final FileDialog fd = new FileDialog( guiFrame, "Select classifier model file...", FileDialog.LOAD );
    //         fd.setDirectory( SEGMENTATION_CLASSIFIER_MODEL_FILE );
    //         fd.setFilenameFilter( new FilenameFilter() {
    //
    //            @Override
    //            public boolean accept( final File dir, final String name ) {
    //               final String lowercaseName = name.toLowerCase();
    //               if ( lowercaseName.endsWith( ".model" ) ) {
    //                  return true;
    //               } else {
    //                  return false;
    //               }
    //            }
    //         } );
    //         fd.setVisible( true );
    //         final String filename = fd.getDirectory() + "/" + fd.getFile();
    //         if ( filename != null ) {
    //            SEGMENTATION_CLASSIFIER_MODEL_FILE = filename;
    //         }
    //      }

    return file;
}

From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java

private void exitItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_exitItemActionPerformed
{//GEN-HEADEREND:event_exitItemActionPerformed

    if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm Exit",
            JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        this.setVisible(false);

        System.exit(1);//w  w  w .ja va 2s  .  c  om
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    if (this.application == null) {
        if (JOptionPane.showConfirmDialog(this, "Do you really want to close the aplication?", "Confirmation",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            saveSettings();//ww  w. j ava2s .  co  m

            this.frameLayers.dispose();
            this.frameToolOptions.dispose();
            this.frameTools.dispose();
            dispose();

            Log.info("The MainForm disposed");
        } else {
            Log.info("Closing rejected by user");
        }
    } else {
        try {
            if (this.application.isReadyForDestroying(this)) {
                Log.info("Destroying application");
                this.application.destroy(this);
                Log.info("Application has been destroyed");
                dispose();
            }
        } catch (Exception ex) {
            Log.error("Error during application close operation", ex);
            dispose();
        }
    }
}

From source file:contactsdirectory.frontend.MainJFrame.java

private void removePerson() {
    if (jListPerson.getSelectedIndex() < 0) {
        JOptionPane.showMessageDialog(this, localizedTexts.getString("noPersonSelected"), "",
                JOptionPane.INFORMATION_MESSAGE);
        return;//w  w w  . java  2 s .  c om
    }

    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(rootPane,
            localizedTexts.getString("deletePersonMsg"), "", JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE)) {
        try {
            Person person = getSelectedPerson();

            jProgressBar.setIndeterminate(true);
            jProgressBar.setVisible(true);

            RemovePersonSwingWorker worker = new RemovePersonSwingWorker(person);
            worker.execute();

            ((DefaultListModel<Contact>) jListPerson.getModel()).removeElement(person);

            jProgressBar.setVisible(false);
            jProgressBar.setIndeterminate(false);
        } catch (RuntimeException e) {
            JOptionPane.showMessageDialog(this, localizedTexts.getString("noPersonRemoved"),
                    localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Invokes the Cluster Shutdown Operation
 *///from w ww. j  a va  2 s  .c  o m
protected void doShutdownCluster() {

    // Consider different messages when there are active jobs
    String message = "Are you sure to shutdown the cluster ?";

    int response = JOptionPane.showConfirmDialog(this, message, "Shutdown Cluster", JOptionPane.YES_NO_OPTION);

    // User chose 'No'
    if (response == JOptionPane.NO_OPTION)
        return;
    JButton shutdownButton = getUIElement("general.shutdown");
    shutdownButton.setEnabled(false);

    showBusyIcon();

    // Shutdown
    onShutdown();
}

From source file:au.com.jwatmuff.eventmanager.gui.main.LoadCompetitionWindow.java

private void saveBackupButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBackupButtonActionPerformed
    DatabaseInfo info = (DatabaseInfo) competitionList.getSelectedValue();
    if (info == null || !info.local)
        return;/*ww  w .j a v a2s .com*/
    JFileChooser chooser = new JFileChooser();
    chooser.setFileFilter(new FileNameExtensionFilter("Event Manager Files", "evm"));
    if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        File file = chooser.getSelectedFile();
        if (!file.getName().toLowerCase().endsWith(".evm"))
            file = new File(file.getAbsolutePath() + ".evm");
        if (file.exists()) {
            int result = JOptionPane.showConfirmDialog(rootPane,
                    file.getName() + " already exists. Overwrite file?", "Save Backup",
                    JOptionPane.YES_NO_OPTION);
            if (result != JOptionPane.YES_OPTION)
                return;
        }
        try {
            File tempDir = Files.createTempDirectory("event-manager").toFile();
            FileUtils.copyDirectory(info.localDirectory, tempDir);

            File lockFile = new File(tempDir, "update.dat.lock");
            lockFile.delete();

            /* change id */
            Properties props = new Properties();
            FileReader fr = new FileReader(new File(tempDir, "info.dat"));
            props.load(fr);
            fr.close();
            props.setProperty("old-UUID", props.getProperty("UUID", "none"));
            props.setProperty("UUID", UUID.randomUUID().toString());
            FileWriter fw = new FileWriter(new File(tempDir, "info.dat"));
            props.store(fw, "");
            fw.close();

            ZipUtils.zipFolder(tempDir, file, false);
        } catch (Exception e) {
            GUIUtils.displayError(this, "Failed to save file: " + e.getMessage());
        }
    }
}