Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

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

Prototype

int WARNING_MESSAGE

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

Click Source Link

Document

Used for warning messages.

Usage

From source file:sanger.team16.gui.genevar.mqtl.snp.CisMQTLSNPPane.java

private void cisSNPPaneActionPerformed(ActionEvent ae) {
    int studyIndex = cbStudy.getSelectedIndex();
    int statisticIndex = cbStatistic.getSelectedIndex();
    //SelectedIndex selectedIndex = new SelectedIndex(studyIndex, this.getStudyReferenceIndex(studyIndex), statisticIndex, taSNP.getText());   //CHANGE 07/12/11 dun know? only do it if ae.getSource() == cbStudy 
    //int referenceIndex = cbReference.getSelectedIndex();   //TODO merge into SelectedIndex
    //int referenceId = ((Reference) cbReference.getSelectedItem()).getId();   //TODO

    if (ae.getSource() == cbStudy) {
        if (studyIndex == 0)
            this.refresh(new SelectedIndex());
        else { //TODO
            //List<MatchedFeature> matchedFeatures = this.getMatchedFeatures(study.getId());
            //this.matchedFeatureTable = new MatchedFeatureTableModel(matchedFeatures).getTable();
            statisticIndex = 0; //ADD 02/12/10

            this.refresh(new SelectedIndex(studyIndex, this.getStudyReferenceIndex(studyIndex), statisticIndex,
                    taSNP.getText()));/* w  ww . j a  va  2s  . c o  m*/
            this.setSubmitButton();
        }
        isDefault = true; //ADD 02/12/10

    } else if (ae.getSource() == cbReference) {
        this.setSubmitButton(); // ADD 18/06/10

    } else if (ae.getSource() == cbStatistic) {
        this.refresh(new SelectedIndex(studyIndex, this.getStudyReferenceIndex(studyIndex), statisticIndex,
                taSNP.getText()));
        this.setSubmitButton();

    } else if (ae.getSource() == bReset) {
        this.refresh(new SelectedIndex());

    } else if (ae.getSource() == bSNPFile) {
        this.ui.addChoosableFileFilter(Message.TXT);

        if (this.ui.showFileChooserOpenDialog(this.ui, null))
            tfSNPFile.setText(this.ui.getFileChooserSelectedFile().getAbsolutePath());

    } else if (ae.getSource() == bSubmit) {
        int distance = new Integer(((String) cbDistance.getSelectedItem()).replaceAll(",", ""));
        if (distance > 100000)
            JOptionPane.showMessageDialog(ui, "No greater than 100 kb", "Distance to SNP",
                    JOptionPane.WARNING_MESSAGE);
        else
            new CisSNPPaneProgressBar().execute();
        //bSubmit.setEnabled(false);
    }
}

From source file:UserInterface.PublisherRole.ViewUserHabitsJPanel.java

private void viewUserHabitsJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewUserHabitsJButtonActionPerformed
    // TODO add your handling code here:
    int selectedRow = userAccountsJTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Please select a row to view!!!", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;/*from  w  ww. ja  va  2  s  .com*/
    }
    UserPotential userPotential = (UserPotential) userAccountsJTable.getValueAt(selectedRow, 0);
    populateUserHabitsTable(userPotential);
    PieDataset pieDataset = createDataset(userPotential);
    populateChart(pieDataset);
}

From source file:net.sf.jabref.JabRefGUI.java

private void setLookAndFeel() {
    try {/*  w  w w. j  a v  a 2s .co m*/
        String lookFeel;
        String systemLookFeel = UIManager.getSystemLookAndFeelClassName();

        if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) {
            // FIXME: Problems with OpenJDK and GTK L&F
            // See https://github.com/JabRef/jabref/issues/393, https://github.com/JabRef/jabref/issues/638
            if (System.getProperty("java.runtime.name").contains("OpenJDK")) {
                // Metal L&F
                lookFeel = UIManager.getCrossPlatformLookAndFeelClassName();
                LOGGER.warn(
                        "There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution.");
            } else {
                lookFeel = systemLookFeel;
            }
        } else {
            lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL);
        }

        // FIXME: Open JDK problem
        if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel)
                && !System.getProperty("java.runtime.name").contains("OpenJDK")) {
            // try to avoid ending up with the ugly Metal L&F
            Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel();
            Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer());
            com.jgoodies.looks.Options.setPopupDropShadowEnabled(true);
            UIManager.setLookAndFeel(lnf);
        } else {
            try {
                UIManager.setLookAndFeel(lookFeel);
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException e) {
                // specified look and feel does not exist on the classpath, so use system l&f
                UIManager.setLookAndFeel(systemLookFeel);
                // also set system l&f as default
                Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLookFeel);
                // notify the user
                JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(),
                        Localization.lang(
                                "Unable to find the requested look and feel and thus the default one is used."),
                        Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);
                LOGGER.warn("Unable to find requested look and feel", e);
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Look and feel could not be set", e);
    }

    // In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms
    boolean overrideDefaultFonts = Globals.prefs.getBoolean(JabRefPreferences.OVERRIDE_DEFAULT_FONTS);
    if (overrideDefaultFonts) {
        int fontSize = Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE);
        UIDefaults defaults = UIManager.getDefaults();
        Enumeration<Object> keys = defaults.keys();
        for (Object key : Collections.list(keys)) {
            if ((key instanceof String) && ((String) key).endsWith(".font")) {
                FontUIResource font = (FontUIResource) UIManager.get(key);
                font = new FontUIResource(font.getName(), font.getStyle(), fontSize);
                defaults.put(key, font);
            }
        }
    }
}

From source file:bio.gcat.gui.BDATool.java

public boolean openFile(File file) {
    try (Reader reader = new InputStreamReader(new FileInputStream(file), CHARSET)) {
        bdaPanel.setBinaryDichotomicAlgorithms(readFrom(reader));
        return true;
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "Could not open file:\n" + e.getMessage(), "Open File",
                JOptionPane.WARNING_MESSAGE);
        return false;
    }/*from  w  ww . j a  va2 s  .com*/
}

From source file:ch.admin.hermes.etl.load.HermesETLApplication.java

/**
 * Ausgabe usage und exit(1)/*from  w  w w .ja v  a2  s .com*/
 */
private static void usage() {
    JOptionPane.showMessageDialog(null,
            "usage: HermesETL [-p <Zielsystem URL>] [-u <User>] [-p <Password>] <JavaScript> <Szenario XML Model>",
            "Fehlerhafter Aufruf von HermesETL", JOptionPane.WARNING_MESSAGE);
    System.exit(-1);
}

From source file:FileTree3.java

protected File[] listFiles() {
    if (!m_file.isDirectory())
        return null;
    try {//from www . ja  v a  2s . com
        return m_file.listFiles();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Error reading directory " + m_file.getAbsolutePath(), "Warning",
                JOptionPane.WARNING_MESSAGE);
        return null;
    }
}

From source file:User.Interface.SupplierAdminRole.ReviewSalesJPanel.java

private void displayBarCharts() {

    //check if the supplier has products in the product list
    if (supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList().size() < 0) {
        JOptionPane.showMessageDialog(this, "No products found from selected supplier.", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;/*from   ww w. j av a  2s .co m*/
    }

    MedicalDevice[] product;
    product = new MedicalDevice[100];

    int numberOfProducts = supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList().size();
    DefaultCategoryDataset dataSetProduct = new DefaultCategoryDataset();

    for (int i = 0; i < numberOfProducts; i++) {
        product[i] = supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList().get(i);
        int soldQuantity = 0;
        soldQuantity = product[i].getSoldQuantity();
        String prodName = product[i].getDeviceName();
        dataSetProduct.setValue(soldQuantity, "Medical Device", prodName);
    }

    JFreeChart chartProduct = ChartFactory.createBarChart("Supplier Performance Report", "Products",
            "Number of Products Sold", dataSetProduct, PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot p1 = chartProduct.getCategoryPlot();
    p1.setRangeGridlinePaint(Color.black);
    ChartFrame frame1 = new ChartFrame("Supplier Performance Report", chartProduct);
    frame1.setVisible(true);
    frame1.setSize(400, 400);
    Point pt1 = new Point(0, 0);
    frame1.setLocation(pt1);
}

From source file:net.sf.firemox.Magic.java

/**
 * Save the settings//from   w  ww  .j  a  va  2s.co  m
 */
public static void saveSettings() {
    // save part of LF_SETTINGS_FILE
    try {
        // save your preferred look and feel
        if (lookAndFeelName.toUpperCase().startsWith("ZIP:" + MToolKit.getRelativePath().toUpperCase())) {
            Configuration.setProperty("preferred",
                    "zip:" + MToolKit
                            .getFile(lookAndFeelName
                                    .substring("zip:".length() + MToolKit.getRelativePath().length() + 1))
                            .toString().replace('\\', '/'));
        } else {
            Configuration.setProperty("preferred", lookAndFeelName);
        }

        // save back colors and wallpapers
        ZoneManager.saveSettings();

        Configuration.setProperty("language", LanguageManager.getLanguage().getKey());
        Configuration.setProperty("automana", MCommonVars.autoMana);
        Configuration.setProperty("autostack", MCommonVars.autoStack);
        Configuration.setProperty("lastTBS", MToolKit.tbsName);

        // write proxy configuration
        Configuration.setProperty("logdisptime", logListing.isDispTime());
        Configuration.setProperty("loglocked", logListing.isLocked());
        Configuration.setProperty("chatdisptime", chatHistoryText.isDispTime());
        Configuration.setProperty("chatlocked", chatHistoryText.isLocked());
        Configuration.setProperty("threshold-colored", PayMana.thresholdColored);
        Configuration.setProperty("border-color", (CardFactory.borderColor == Color.BLACK ? "black"
                : CardFactory.borderColor == Color.WHITE ? "white" : "gold"));

        targetTimer.saveSettings();
        CardFactory.saveSettings();
        DatabaseFactory.saveCache();
        Configuration.getConfiguration().save();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(magicForm, LanguageManager.getString("savelfpb") + " : " + e.getMessage(),
                LanguageManager.getString("error"), JOptionPane.WARNING_MESSAGE);
    }

    // save the tbs settings
    MdbLoader.saveTBSSettings();
}

From source file:dbseer.gui.actions.ExplainChartAction.java

public void printExplanations() {
    final StatisticalPackageRunner runner = DBSeerGUI.runner;
    int explanationColumnCount = 6;
    int predicateColumnCount = 5;

    int explanationRowCount = 0;
    int predicateRowCount = 0;
    double maxConfidence = Double.MIN_VALUE;

    this.explanations.clear();
    DefaultListModel explanationListModel = panel.getControlPanel().getExplanationListModel();
    explanationListModel.clear();/*from w ww  .  ja  va 2  s  .  com*/

    JTextField confidenceThresholdTextField = panel.getControlPanel().getConfidenceThresholdTextField();
    if (!UserInputValidator.validateNumber(confidenceThresholdTextField.getText().trim(),
            "Confidence Threshold", true)) {
        return;
    }
    confidenceThreshold = Double.parseDouble(confidenceThresholdTextField.getText().trim());
    if (confidenceThreshold < 0 || confidenceThreshold > 100) {
        JOptionPane.showMessageDialog(null, "Confidence threshold must be between 1 and 100.", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;
    }

    try {
        Object[] explanations = (Object[]) runner.getVariableCell("explanations");
        explanationRowCount = explanations.length / explanationColumnCount;
        for (int r = 0; r < explanationRowCount; ++r) {
            String causeName = (String) explanations[r];
            double[] confidence = (double[]) explanations[r + explanationRowCount * 1];
            Object[] predicates = (Object[]) explanations[r + explanationRowCount * 5];

            if (runner instanceof OctaveRunner) {
                for (int i = 0; i < predicates.length; ++i) {
                    if (predicates[i] instanceof OctaveString) {
                        OctaveString str = (OctaveString) predicates[i];
                        predicates[i] = str.getString();
                    } else if (predicates[i] instanceof OctaveDouble) {
                        OctaveDouble val = (OctaveDouble) predicates[i];
                        predicates[i] = val.getData();
                    }
                }
            }

            DBSeerCausalModel explanation = new DBSeerCausalModel(causeName, confidence[0]);
            explanation.getPredicates();

            predicateRowCount = predicates.length / predicateColumnCount;
            for (int p = 0; p < predicateRowCount; ++p) {
                String predicateName = (String) predicates[p];
                double[] bounds = (double[]) predicates[p + predicateRowCount * 1];
                DBSeerPredicate predicate = new DBSeerPredicate(predicateName, bounds[0], bounds[1]);
                explanation.getPredicates().add(predicate);
            }

            this.explanations.add(explanation);

            if (maxConfidence < confidence[0]) {
                maxConfidence = confidence[0];
            }
        }
    } catch (Exception e) {
        DBSeerExceptionHandler.handleException(e);
    }

    //      double[] mockupConf = {82.74, 21.49, 14.23, 7.86};

    int rank = 1;
    for (DBSeerCausalModel explanation : explanations) {
        if (explanation.getConfidence() > confidenceThreshold) {
            //            String output = String.format("%d. %s\n", rank++, explanation.toString());
            // temp
            //            if (rank <= 4)
            //            {
            //               String output = String.format("%d. %s (%.2f%%)\n", rank, explanation.getCause(), mockupConf[rank - 1]);
            //               explanationListModel.addElement(output);
            //               rank++;
            //            }
            //            else
            //            {
            //               String output = String.format("%d. %s\n", rank++, explanation.toString());
            //               explanationListModel.addElement(output);
            //            }
            String output = String.format("%d. %s\n", rank++, explanation.toString());
            explanationListModel.addElement(output);
        }
    }

    if (maxConfidence < confidenceThreshold) {
        String output = String.format(
                "There are no possible causes with the confidence higher than threshold (%.2f%%).\n",
                confidenceThreshold);
        console.append(output);
        console.append("Showing the current predicates.\n");
    }

    printPredicates();
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRResultsController.java

@Override
protected void tryToCreateFile(File pdfFile) {
    try {//from w ww  .j a va 2s .co  m
        boolean success = pdfFile.createNewFile();
        if (success) {
            doseResponseController.showMessage("Pdf Report successfully created!", "Report created",
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            Object[] options = { "Yes", "No", "Cancel" };
            int showOptionDialog = JOptionPane.showOptionDialog(null,
                    "File already exists. Do you want to replace it?", "", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[2]);
            // if YES, user wants to delete existing file and replace it
            if (showOptionDialog == 0) {
                boolean delete = pdfFile.delete();
                if (!delete) {
                    return;
                }
                // if NO, returns already existing file
            } else if (showOptionDialog == 1) {
                return;
            }
        }
    } catch (IOException ex) {
        doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    try (FileOutputStream fileOutputStream = new FileOutputStream(pdfFile)) {
        // actually create PDF file
        createPdfFile(fileOutputStream);
    } catch (IOException ex) {
        doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error",
                JOptionPane.ERROR_MESSAGE);
    }
}