Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

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

Prototype

int OK_OPTION

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

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:Forms.CreateGearForm.java

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

From source file:com.sshtools.common.ui.SshToolsConnectionHostTab.java

/**
 *
 *
 * @return//from  w  w w .  j a va 2s.  c  o  m
 */
public boolean validateTab() {
    // Validate that we have enough information
    if (jTextHostname.getText().equals("") || jTextPort.getText().equals("")
    /* || jTextUsername.getText().equals("")*/) {
        JOptionPane.showMessageDialog(this, "Please enter all details!", "Connect", JOptionPane.OK_OPTION);

        return false;
    }

    // Setup the authentications selected
    java.util.List chosen = getChosenAuth();

    if (chosen != null) {
        Iterator it = chosen.iterator();

        while (it.hasNext()) {
            String method = (String) it.next();

            try {
                SshAuthenticationClient auth = SshAuthenticationClientFactory.newInstance(method, profile);
            } catch (AlgorithmNotSupportedException anse) {
                JOptionPane.showMessageDialog(this, method + " is not supported!");

                return false;
            }
        }
    }

    return true;
}

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

public void reinitializeGroovyClipboardFormatters() {
    String dialogTitle = "Reinitialize example groovy clipboard formatters?";
    String message = "This overwrites all example groovy clipboard formatters. Other clipboard formatters are not changed!\nReinitialize example groovy clipboard formatters 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;//from ww  w. j av a  2 s .  c o m
    }

    applicationPreferences.installExampleClipboardFormatters();
}

From source file:gov.nih.nci.nbia.StandaloneDMDispatcher.java

private void install(String downloadUrl) {
    Double vNum = 0.0;//from ww  w .j av a 2s .  co  m
    if (appVersion != null) {
        vNum = Double.parseDouble(appVersion);
    }
    String installerPath = getInstallerName(downloadUrl);
    if (os.contains("windows")) {
        try {
            Runtime.getRuntime().exec("msiexec /i \"" + installerPath + "\"");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (os.startsWith("mac")) {
        try {
            Runtime.getRuntime().exec(new String[] { "/usr/bin/open", installerPath });
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        JLabel pwLabel = new JLabel("Sudo Password");
        JTextField password = new JPasswordField();
        Object[] objs = { pwLabel, password };
        int result = JOptionPane.showConfirmDialog(null, objs, "Please enter a sudo password",
                JOptionPane.OK_CANCEL_OPTION);
        String pas = null;
        if (result == JOptionPane.OK_OPTION) {
            pas = password.getText();
        }

        if (pas != null) {
            if (os.equals("CentOS")) {
                // sudo yum install TCIADownloader-1.0-1.x86_64.rpm
                try {
                    String upgradCmd = "/usr/bin/sudo -S yum -q -y remove TCIADownloader.x86_64;/usr/bin/sudo -S yum -y -q install ";
                    if (vNum >= 3.2)
                        upgradCmd = "/usr/bin/sudo -S yum -q -y remove NBIADataRetriever.x86_64;/usr/bin/sudo -S yum -y -q install ";

                    String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath };

                    Process pb = Runtime.getRuntime().exec(cmd);
                    BufferedWriter writer = null;
                    writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream()));
                    writer.write(pas);
                    writer.write('\n');
                    writer.flush();

                    String status = null;

                    if (pb.waitFor() == 0) {
                        status = "successfully";
                    } else {
                        status = "unsuccessfully";
                    }

                    JOptionPane.showMessageDialog(null,
                            "Installation of new version of NBIA Data Retriever is completed " + status + ".");
                } catch (IOException | InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else if (os.equals("Ubuntu")) {
                // sudo dpkg -i tciadownloader_1.0-2_amd64.deb
                String upgradCmd = "/usr/bin/sudo -S dpkg -i ";
                if (vNum >= 3.2)
                    upgradCmd = "/usr/bin/sudo -S dpkg -i nbia-data-retriever; /usr/bin/sudo -S dpkg -i ";
                try {
                    String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath };

                    Process pb = Runtime.getRuntime().exec(cmd);
                    BufferedWriter writer = null;
                    writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream()));
                    writer.write(pas);
                    writer.write('\n');
                    writer.flush();

                    String status = null;

                    if (pb.waitFor() == 0) {
                        status = "successfully";
                    } else {
                        status = "unsuccessfully";
                    }

                    JOptionPane.showMessageDialog(null,
                            "Installation of new version of NBIA Data Retriever is completed " + status + ".");
                } catch (IOException | InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java

/**
 * Run a file download operation./*  w w  w .ja v  a  2  s  .c  o  m*/
 */
private void downloadFile() {
    String bibtexKey = entryEditor.getEntry().getCiteKey();
    if (bibtexKey == null) {
        int answer = JOptionPane.showConfirmDialog(frame,
                Localization.lang("This entry has no BibTeX key. Generate key now?"),
                Localization.lang("Download file"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (answer == JOptionPane.OK_OPTION) {
            ActionListener l = entryEditor.getGenerateKeyAction();
            l.actionPerformed(null);
            bibtexKey = entryEditor.getEntry().getCiteKey();
        }
    }
    DownloadExternalFile def = new DownloadExternalFile(frame,
            frame.getCurrentBasePanel().getBibDatabaseContext(), bibtexKey);
    try {
        def.download(this);
    } catch (IOException ex) {
        LOGGER.warn("Cannot download.", ex);
    }
}

From source file:view.statistics.IssueChart.java

private void showChartBtn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showChartBtn1ActionPerformed
    String option = "" + optionCombo.getSelectedItem();
    String chartType = "" + chartCombo.getSelectedItem();
    if (option.equals("Blood Components")) {
        try {/*from  w w  w.j a  v  a  2 s  . co  m*/
            int cryoCount = 0;
            int ffpCount = 0;
            int freshBloodCount = 0;
            int plasmaCount = 0;
            int plateletsCount = 0;

            ResultSet rst = null;
            String year = "" + yearCombo.getSelectedItem();
            String month = "" + monthCombo.getSelectedItem();
            rst = IssueController.getIssueInfo(year, month);

            while (rst.next()) {

                String type = rst.getString("BloodType");
                if (type.equalsIgnoreCase("CRYO")) {
                    cryoCount++;
                } else if (type.equalsIgnoreCase("FFP")) {
                    ffpCount++;
                } else if (type.equalsIgnoreCase("Fresh Blood")) {
                    freshBloodCount++;
                } else if (type.equalsIgnoreCase("Plasma/CSP")) {
                    plasmaCount++;
                } else if (type.equalsIgnoreCase("Platelets")) {
                    plateletsCount++;
                }
            }

            if (chartType.equals("Pie Chart")) {
                DefaultPieDataset piedataset = new DefaultPieDataset();
                piedataset.setValue("CRYO", cryoCount);
                piedataset.setValue("FFP", ffpCount);
                piedataset.setValue("Fresh Blood", freshBloodCount);
                piedataset.setValue("Plasma/CSP", plasmaCount);
                piedataset.setValue("Platelets", plateletsCount);
                JFreeChart chart = ChartFactory.createPieChart3D("Issued Blood Components", piedataset, true,
                        true, true);
                ChartPanel panel = new ChartPanel(chart);
                chart.setBackgroundPaint(Color.PINK);
                chart.getTitle().setPaint(Color.RED);
                chartArea.add(panel);
                panel.setSize(chartArea.getSize());
                panel.setVisible(true);
            } else {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                dataset.setValue(cryoCount, "Issued Values", "CRYO");
                dataset.setValue(ffpCount, "Issued Values", "FFP");
                dataset.setValue(freshBloodCount, "Issued Values", "Fresh Blood");
                dataset.setValue(plasmaCount, "Issued Values", "Plasma/CSP");
                dataset.setValue(plateletsCount, "Issued Values", "Platelets");
                if (chartType.equals("Bar Chart")) {
                    JFreeChart chart = ChartFactory.createBarChart3D("Issued Bloood Components",
                            "Blood Component", "Issued Values", dataset, PlotOrientation.VERTICAL, false, true,
                            false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                } else if (chartType.equals("Line Chart")) {
                    JFreeChart chart = ChartFactory.createLineChart3D("Issued Blood Components",
                            "Blood Component", "Issued Values", dataset, PlotOrientation.VERTICAL, false, true,
                            false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                }
            }

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "-1Data Error!", "Warning!", JOptionPane.OK_OPTION);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IssueChart.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if (option.equals("Blood Groups")) {
        try {
            int Apos = 0;
            int Bpos = 0;
            int Aneg = 0;
            int Bneg = 0;
            int ABpos = 0;
            int Opos = 0;
            int ABneg = 0;
            int Oneg = 0;

            ResultSet rst = null;
            String year = "" + yearCombo.getSelectedItem();
            String month = "" + monthCombo.getSelectedItem();

            rst = IssueController.getIssueInfo(year, month);

            while (rst.next()) {

                String type = rst.getString("BloodGroup");
                if (type.equalsIgnoreCase("A+")) {
                    Apos++;
                } else if (type.equalsIgnoreCase("B+")) {
                    Bpos++;
                } else if (type.equalsIgnoreCase("A-")) {
                    Aneg++;
                } else if (type.equalsIgnoreCase("B-")) {
                    Bneg++;
                } else if (type.equalsIgnoreCase("AB+")) {
                    ABpos++;
                } else if (type.equalsIgnoreCase("AB-")) {
                    ABneg++;
                } else if (type.equalsIgnoreCase("O+")) {
                    Opos++;
                } else if (type.equalsIgnoreCase("O-")) {
                    Oneg++;
                }
            }

            if (chartType.equals("Pie Chart")) {
                DefaultPieDataset piedataset = new DefaultPieDataset();
                piedataset.setValue("A+", Apos);
                piedataset.setValue("A-", Aneg);
                piedataset.setValue("B+", Bpos);
                piedataset.setValue("B-", Bneg);
                piedataset.setValue("AB+", ABpos);
                piedataset.setValue("AB-", ABneg);
                piedataset.setValue("O+", Opos);
                piedataset.setValue("O-", Oneg);

                JFreeChart chart = ChartFactory.createPieChart3D("Issued Blood Groups", piedataset, true, true,
                        true);
                ChartPanel panel = new ChartPanel(chart);
                chart.setBackgroundPaint(Color.PINK);
                chart.getTitle().setPaint(Color.RED);
                chartArea.add(panel);
                panel.setSize(chartArea.getSize());
                panel.setVisible(true);
            } else {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                dataset.setValue(Apos, "Issued Values", "A+");
                dataset.setValue(Aneg, "Issued Values", "A-");
                dataset.setValue(Bpos, "Issued Values", "B+");
                dataset.setValue(Bneg, "Issued Values", "B-");
                dataset.setValue(ABpos, "Issued Values", "AB+");
                dataset.setValue(ABneg, "Issued Values", "AB-");
                dataset.setValue(Opos, "Issued Values", "O+");
                dataset.setValue(Oneg, "Issued Values", "O-");
                if (chartType.equals("Bar Chart")) {
                    JFreeChart chart = ChartFactory.createBarChart3D("Issued Bloood Groups", "Blood Group",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                } else if (chartType.equals("Line Chart")) {
                    JFreeChart chart = ChartFactory.createLineChart3D("Issued Blood Groups", "Blood Group",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);
                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                }

            }
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "0Data Error!", "Warning!", JOptionPane.OK_OPTION);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IssueChart.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if (option.equals("Gender")) {
        try {
            int male = 0;
            int female = 0;

            ResultSet rst = null;
            String year = "" + yearCombo.getSelectedItem();
            String month = "" + monthCombo.getSelectedItem();
            rst = IssueController.getRequesteeInfo(year, month);

            while (rst.next()) {

                String type = rst.getString("Gender");
                if (type.equalsIgnoreCase("Male")) {
                    male++;
                } else if (type.equalsIgnoreCase("Female")) {
                    female++;
                }
            }

            if (chartType.equals("Pie Chart")) {
                DefaultPieDataset piedataset = new DefaultPieDataset();
                piedataset.setValue("Male", male);
                piedataset.setValue("Female", female);

                JFreeChart chart = ChartFactory.createPieChart3D("Blood Requestees", piedataset, true, true,
                        true);
                ChartPanel panel = new ChartPanel(chart);
                chart.setBackgroundPaint(Color.PINK);
                chart.getTitle().setPaint(Color.RED);
                chartArea.add(panel);
                panel.setSize(chartArea.getSize());
                panel.setVisible(true);
            } else {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                dataset.setValue(male, "", "Male");
                dataset.setValue(female, "", "Female");

                if (chartType.equals("Bar Chart")) {
                    JFreeChart chart = ChartFactory.createBarChart3D("Blood Requestees", "Gender", "", dataset,
                            PlotOrientation.VERTICAL, false, true, false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                } else if (chartType.equals("Line Chart")) {
                    JFreeChart chart = ChartFactory.createLineChart3D("Blood Requestees", "Gender", "", dataset,
                            PlotOrientation.VERTICAL, false, true, false);
                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                }
            }
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "1Data Error!", "Warning!", JOptionPane.OK_OPTION);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IssueChart.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if (option.equals("Hospitals")) {
        try {

            String[] hospitals = new String[10];
            int[] hospitalCount = new int[10];
            int noOfHospitals = 0;
            ResultSet rst = null;
            String year = "" + yearCombo.getSelectedItem();
            String month = "" + monthCombo.getSelectedItem();
            rst = SampleDetailsController.getAllHospitals();
            while (rst.next()) {
                hospitals[noOfHospitals] = rst.getString("Name");
                hospitalCount[noOfHospitals] = 0;
                noOfHospitals++;
            }

            rst = IssueController.getRequesteeInfo(year, month);

            while (rst.next()) {
                String type = rst.getString("Hospital");
                for (int i = 0; i < noOfHospitals; i++) {
                    if (type.equalsIgnoreCase(hospitals[i])) {
                        hospitalCount[i]++;
                    }
                }
            }

            if (chartType.equals("Pie Chart")) {
                DefaultPieDataset piedataset = new DefaultPieDataset();
                for (int i = 0; i < noOfHospitals; i++) {
                    piedataset.setValue(hospitals[i], hospitalCount[i]);
                }

                JFreeChart chart = ChartFactory.createPieChart3D("Issued Hospitals", piedataset, true, true,
                        true);
                ChartPanel panel = new ChartPanel(chart);
                chart.setBackgroundPaint(Color.PINK);
                chart.getTitle().setPaint(Color.RED);
                chartArea.add(panel);
                panel.setSize(chartArea.getSize());
                panel.setVisible(true);
            } else {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                for (int i = 0; i < noOfHospitals; i++) {
                    dataset.setValue(hospitalCount[i], "Issued Values", hospitals[i]);
                }

                if (chartType.equals("Bar Chart")) {
                    JFreeChart chart = ChartFactory.createBarChart3D("Issued Hospitals", "Hospital",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                } else if (chartType.equals("Line Chart")) {
                    JFreeChart chart = ChartFactory.createLineChart3D("Issued Hospitals", "Hospital",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);
                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                }
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(null, "2Data Error!", "Warning!", JOptionPane.OK_OPTION);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IssueChart.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if (option.equals("Age Groups")) {
        try {
            int[] ages = new int[10];
            for (int i = 0; i < 10; i++) {
                ages[i] = 0;
            }
            ResultSet rst = null;
            String year = "" + yearCombo.getSelectedItem();
            String month = "" + monthCombo.getSelectedItem();
            rst = IssueController.getRequesteeInfo(year, month);

            while (rst.next()) {
                int age = Integer.parseInt(rst.getString("Age"));
                if (age <= 10 && age > 0) {
                    ages[0]++;
                } else if (age <= 20 && age > 10) {
                    ages[1]++;
                } else if (age <= 30 && age > 20) {
                    ages[2]++;
                } else if (age <= 40 && age > 30) {
                    ages[3]++;
                } else if (age <= 50 && age > 40) {
                    ages[4]++;
                } else if (age <= 60 && age > 50) {
                    ages[5]++;
                } else if (age <= 70 && age > 60) {
                    ages[6]++;
                } else if (age <= 80 && age > 70) {
                    ages[7]++;
                } else if (age <= 90 && age > 80) {
                    ages[8]++;
                } else if (age <= 100 && age > 90) {
                    ages[9]++;
                }
            }

            rst = IssueController.getRequesteeInfo(year, month);

            if (chartType.equals("Pie Chart")) {
                DefaultPieDataset piedataset = new DefaultPieDataset();
                for (int i = 0; i < 10; i++) {
                    piedataset.setValue(i * 10 + "-" + (i * 10 + 10), ages[i]);
                }

                JFreeChart chart = ChartFactory.createPieChart3D("Issued Age Groups", piedataset, true, true,
                        true);
                ChartPanel panel = new ChartPanel(chart);
                chart.setBackgroundPaint(Color.PINK);
                chart.getTitle().setPaint(Color.RED);
                chartArea.add(panel);
                panel.setSize(chartArea.getSize());
                panel.setVisible(true);
            } else {
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                for (int i = 0; i < 10; i++) {
                    dataset.setValue(ages[i], "Issued Values", i * 10 + "-" + (i * 10 + 10));
                }

                if (chartType.equals("Bar Chart")) {
                    JFreeChart chart = ChartFactory.createBarChart3D("Issued Age Groups", "Age Groups",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);

                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                } else if (chartType.equals("Line Chart")) {
                    JFreeChart chart = ChartFactory.createLineChart3D("Issued Age Groups", "Age Groups",
                            "Issued Values", dataset, PlotOrientation.VERTICAL, false, true, false);
                    chart.setBackgroundPaint(Color.PINK);
                    chart.getTitle().setPaint(Color.RED);

                    CategoryPlot p = chart.getCategoryPlot();
                    p.setRangeGridlinePaint(Color.BLUE);
                    ChartPanel panel = new ChartPanel(chart);
                    chartArea.add(panel);
                    panel.setSize(chartArea.getSize());
                    panel.setVisible(true);
                }
            }
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "3Data Error!", "Warning!", JOptionPane.OK_OPTION);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IssueChart.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:sk.uniza.fri.pds.spotreba.energie.gui.MainGui.java

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
    final StatistikaSpotriebParams params = new StatistikaSpotriebParams();
    int option = showUniversalInputDialog(params, "tatistika poda typu a kategrie");
    if (option == JOptionPane.OK_OPTION) {
        new SwingWorker<List, RuntimeException>() {
            @Override//ww w  . j av  a2  s . com
            protected List doInBackground() throws Exception {
                try {
                    return SeHistoriaService.getInstance().getOveralStatistics(params);
                } catch (RuntimeException e) {
                    publish(e);
                    return null;
                }
            }

            @Override
            protected void done() {
                try {
                    List data = get();
                    showJTable(CelkovaStatistika.class, data);
                } catch (InterruptedException | ExecutionException ex) {
                    Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            @Override
            protected void process(List<RuntimeException> chunks) {
                if (chunks.size() > 0) {
                    showException("Chyba", chunks.get(0));
                }
            }

        }.execute();
    }
}

From source file:gui.DownloadPanel.java

public void actionClearAllCompleted() {
    int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to delete all completed files?",
            "Confirm delete all", JOptionPane.OK_CANCEL_OPTION);
    if (action == JOptionPane.OK_OPTION) {
        List<Download> selectedDownloads = downloadsTableModel.getDownloadsByStatus(DownloadStatus.COMPLETE);

        clearing = true;/*from   w w  w  .ja  v a  2  s  .c o m*/
        downloadsTableModel.clearDownloads(selectedDownloads);
        downloadList.removeAll(selectedDownloads);
        clearing = false;

        try {
            for (Download download : selectedDownloads) {
                if (selectedDownload == download)
                    selectedDownload = null;
                DownloadDialog downloadDialog = getDownloadDialogByDownload(download);
                downloadDialogs.remove(downloadDialog);
                downloadDialog.removeDownloadInfoListener(this);
                downloadDialog.dispose();
                databaseController.delete(download.getId());
                FileUtils.forceDelete(new File(
                        download.getDownloadRangePath() + File.separator + download.getDownloadName())); // todo must again
            }
        } catch (SQLException | IOException e) {
            e.printStackTrace();
        }
        tableSelectionChanged();
    }
}

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

public void deleteAllLogs() {
    String dialogTitle = "Delete all log files?";
    String message = "This deletes *all* log files, even the Lilith logs and the global logs!\nDelete all log files 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;//from  w  ww .ja v a2  s.  c o m
    }

    mainFrame.deleteAllLogs();
}

From source file:com.polivoto.vistas.Acceso.java

private void usuarioInvalido() {
    JOptionPane.showMessageDialog(null, "Usuario invlido o Contrasea incorrecta", "Error",
            JOptionPane.OK_OPTION,
            new javax.swing.ImageIcon(getClass().getResource("/com/polivoto/imagenes/error.png")));
}