Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

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

Prototype

int ERROR_MESSAGE

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

Click Source Link

Document

Used for error messages.

Usage

From source file:fr.crnan.videso3d.ihm.PLNSPanel.java

private JToolBar createToolbar() {
    JToolBar toolbar = new JToolBar();

    JButton newGraph = new JButton("Nouveau");
    newGraph.addActionListener(new ActionListener() {

        @Override//from   ww w. j a v  a  2s  .  c  o m
        public void actionPerformed(ActionEvent e) {
            PLNSChartCreateUI chartCreator = new PLNSChartCreateUI(PLNSPanel.this);
            JFreeChart chart = null;
            try {
                if (chartCreator.showDialog(PLNSPanel.this)) {
                    switch (chartCreator.getChartType()) {
                    case 0://XY
                        JDBCXYDataset dataset = new JDBCXYDataset(plnsAnalyzer.getConnection());
                        dataset.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createXYAreaChart(chartCreator.getChartTitle(),
                                chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset,
                                PlotOrientation.VERTICAL, false, true, false);
                        break;
                    case 1://Pie
                        JDBCPieDataset dataset1 = new JDBCPieDataset(plnsAnalyzer.getConnection());
                        dataset1.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createPieChart3D(chartCreator.getChartTitle(), dataset1, false,
                                true, false);
                        break;
                    case 2://Category
                        JDBCCategoryDataset dataset2 = new JDBCCategoryDataset(plnsAnalyzer.getConnection());
                        dataset2.executeQuery(chartCreator.getRequest());
                        chart = ChartFactory.createBarChart(chartCreator.getChartTitle(),
                                chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset2,
                                PlotOrientation.VERTICAL, false, true, false);
                        break;
                    default:
                        break;
                    }
                }
            } catch (SQLException e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(PLNSPanel.this,
                        "<html>L'excution de la requte a chou :<br />" + e1 + "</html>",
                        "Impossible de crer le graphique", JOptionPane.ERROR_MESSAGE);
            }
            if (chart != null)
                addChart(chart);

        }
    });

    toolbar.add(newGraph);

    JButton retile = new JButton("Rarranger");
    retile.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            desktop.tile(true);
        }
    });
    toolbar.add(retile);

    return toolbar;
}

From source file:com.dragoniade.deviantart.deviation.SearchRss.java

public List<Deviation> search(ProgressDialog progress, Collection collection) {
    if (user == null) {
        throw new IllegalStateException("You must set the user before searching.");
    }// w w w.  j  a v  a  2 s  .c  om
    if (search == null) {
        throw new IllegalStateException("You must set the search type before searching.");
    }
    if (total < 0) {
        progress.setText("Fetching total (0)");
        total = retrieveTotal(progress, collection);
        progress.setText("Total: " + total);
    }

    String searchQuery = search.getSearch().replace("%username%", user);
    String queryString = "http://backend.deviantart.com/rss.xml?q=" + searchQuery
            + (collection == null ? "" : "/" + collection.getId()) + "&type=deviation&offset=" + offset;
    GetMethod method = new GetMethod(queryString);
    List<Deviation> results = new ArrayList<Deviation>(OFFSET);
    try {
        int sc = -1;
        do {
            sc = client.executeMethod(method);
            if (sc != 200) {
                LoggableException ex = new LoggableException(method.getResponseBodyAsString());
                Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex);

                int res = DialogHelper.showConfirmDialog(owner,
                        "An error has occured when contacting deviantART : error " + sc + ". Try again?",
                        "Continue?", JOptionPane.YES_NO_OPTION);
                if (res == JOptionPane.NO_OPTION) {
                    return null;
                }
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                }
            }
        } while (sc != 200);

        XmlToolkit toolkit = XmlToolkit.getInstance();

        Element responses = toolkit.parseDocument(method.getResponseBodyAsStream());
        method.releaseConnection();

        HashMap<String, String> prefixes = new HashMap<String, String>();
        prefixes.put("media", responses.getOwnerDocument().lookupNamespaceURI("media"));
        NamespaceContext context = toolkit.getNamespaceContext(prefixes);

        List<?> deviations = toolkit.getMultipleNodes(responses, "channel/item");
        if (deviations.size() == 0) {
            return results;
        }

        for (Object obj : deviations) {
            Element deviation = (Element) obj;

            Deviation da = new Deviation();
            da.setId(getId(toolkit.getNodeAsString(deviation, "guid")));
            da.setArtist(toolkit.getNodeAsString(deviation, "media:credit", context));
            da.setCategory(toolkit.getNodeAsString(deviation, "media:category", context));
            da.setTitle(toolkit.getNodeAsString(deviation, "media:title", context));
            da.setUrl(toolkit.getNodeAsString(deviation, "link"));
            da.setTimestamp(parseDate(toolkit.getNodeAsString(deviation, "pubDate")));
            da.setMature(!"nonadult".equals(toolkit.getNodeAsString(deviation, "media:rating", context)));
            da.setCollection(collection);

            Element documentNode = (Element) toolkit.getSingleNode(deviation,
                    "media:content[@medium='document']", context);
            Element imageNode = (Element) toolkit.getSingleNode(deviation, "media:content[@medium='image']",
                    context);
            Element videoNode = (Element) toolkit.getSingleNode(deviation, "media:content[@medium='video']",
                    context);

            if (imageNode != null) {
                String content = imageNode.getAttribute("url");
                String filename = Deviation.extractFilename(content);
                da.setImageDownloadUrl(content);
                da.setImageFilename(filename);

                da.setResolution(imageNode.getAttribute("width") + "x" + imageNode.getAttribute("height"));
            }

            if (documentNode != null) {
                String content = documentNode.getAttribute("url");
                String filename = Deviation.extractFilename(content);
                da.setDocumentDownloadUrl(content);
                da.setDocumentFilename(filename);
            }

            if (videoNode != null) {
                String content = videoNode.getAttribute("url");
                if (!content.endsWith("/")) {
                    content = content + "/";
                }
                String filename = Deviation.extractFilename(content);
                da.setDocumentDownloadUrl(content);
                da.setDocumentFilename(filename);
            }

            results.add(da);
        }
        offset = offset + deviations.size();
        return results;
    } catch (HttpException e) {
        DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    } catch (IOException e) {
        DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }
}

From source file:org.jdal.swing.form.FormUtils.java

/**
 * Show error message/*www  .j a v a2s.  c  om*/
 * @param parent component parent
 * @param message message to show
 */
public static void showError(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, "Error", JOptionPane.ERROR_MESSAGE);
}

From source file:net.sf.jabref.gui.preftabs.PreviewPrefsTab.java

public PreviewPrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;

    GridBagLayout layout = new GridBagLayout();
    firstPanel.setLayout(layout);//from   w  w w .jav a2s.  c o m
    secondPanel.setLayout(layout);

    setLayout(layout);
    JLabel lab = new JLabel(Localization.lang("Preview") + " 1");
    GridBagConstraints layoutConstraints = new GridBagConstraints();
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.insets = new Insets(2, 2, 2, 2);
    layout.setConstraints(lab, layoutConstraints);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstScrollPane, layoutConstraints);
    firstPanel.add(firstScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.gridwidth = 1;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layout.setConstraints(testButton, layoutConstraints);
    firstPanel.add(testButton);
    layout.setConstraints(defaultButton, layoutConstraints);
    firstPanel.add(defaultButton);
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    JPanel newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    firstPanel.add(newPan);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layout.setConstraints(lab, layoutConstraints);
    // p2.add(lab);
    layoutConstraints.weighty = 1;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layout.setConstraints(secondScrollPane, layoutConstraints);
    secondPanel.add(secondScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.gridwidth = 1;
    layout.setConstraints(testButton2, layoutConstraints);
    secondPanel.add(testButton2);
    layout.setConstraints(defaultButton2, layoutConstraints);
    secondPanel.add(defaultButton2);
    layoutConstraints.gridwidth = 1;
    newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    secondPanel.add(newPan);

    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lab = new JLabel(Localization.lang("Preview") + " 1");
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstPanel, layoutConstraints);
    add(firstPanel);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layoutConstraints.weighty = 0;
    JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL);
    layout.setConstraints(sep, layoutConstraints);
    add(sep);
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(secondPanel, layoutConstraints);
    add(secondPanel);
    layoutConstraints.weighty = 0;

    defaultButton.addActionListener(e -> {
        String tmp = layout1.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_0);
        layout1.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_0).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_0, tmp);
    });

    defaultButton2.addActionListener(e -> {
        String tmp = layout2.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_1);
        layout2.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_1).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_1, tmp);
    });

    testButton.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout1.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, testPanel, Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });

    testButton2.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout2.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, new JScrollPane(testPanel), Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });
}

From source file:eu.ggnet.dwoss.util.HtmlDialog.java

private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed
    try {//from w  w  w .j ava  2  s . c  o m
        documentTextPane.print();
    } catch (PrinterException ex) {
        JOptionPane.showMessageDialog(this, ex, "PrinterException", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java

private void init() {
    setupPopupMenu();//from   w w w. j  a  v a 2s . c  o m

    addButton.addActionListener(actionEvent -> {
        AddFileDialog addDialog = new AddFileDialog();
        addDialog.setDirectoryPath(preferences.getCurrentStyle());
        addDialog.setVisible(true);
        addDialog.getFileName().ifPresent(fileName -> {
            if (loader.addStyleIfValid(fileName)) {
                preferences.setCurrentStyle(fileName);
            }
        });
        updateStyles();

    });
    addButton.setToolTipText(Localization.lang("Add style file"));

    removeButton.addActionListener(removeAction);
    removeButton.setToolTipText(Localization.lang("Remove style"));

    // Create a preview panel for previewing styles
    // Must be done before creating the table to avoid NPEs
    preview = new PreviewPanel(null, null, "");
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);

    setupTable();
    updateStyles();

    // Build dialog
    diag = new JDialog(frame, Localization.lang("Select style"), true);

    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref",
            "pref, 4dlu, 100dlu:grow, 4dlu, pref, 4dlu, fill:100dlu"));
    builder.add(Localization.lang("Select one of the available styles or add a style file from disk.")).xyw(1,
            1, 5);
    builder.add(new JScrollPane(table)).xyw(1, 3, 5);
    builder.add(addButton).xy(3, 5);
    builder.add(removeButton).xy(5, 5);
    builder.add(preview).xyw(1, 7, 5);
    builder.padding("5dlu, 5dlu, 5dlu, 5dlu");

    diag.add(builder.getPanel(), BorderLayout.CENTER);

    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                JOptionPane.showMessageDialog(diag, Localization.lang("You must select a valid style file."),
                        Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);

    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);

    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);

    diag.pack();

    PositionWindow pw = new PositionWindow(diag, JabRefPreferences.STYLES_POS_X, JabRefPreferences.STYLES_POS_Y,
            JabRefPreferences.STYLES_SIZE_X, JabRefPreferences.STYLES_SIZE_Y);
    pw.setWindowPosition();
}

From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java

protected void createActionComponents(JToolBar toolBar) {
    super.createActionComponents(toolBar);
    JButton button;//from  www  . ja  va2 s  . c o m

    /**************** wiki Tab ****************/
    Action linkAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {

            try {
                //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity");
                parentApplet.getAppletContext().showDocument(new java.net.URL(
                        "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_2D_PointSegmentation_EM_Mixture"),
                        "SOCR EduMaterials Activities 2D PointSegmentation EM Mixture");
            } catch (MalformedURLException Exc) {
                JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE);
                Exc.printStackTrace();
            }

        }
    };

    button = toolBar.add(linkAction);
    button.setText(" WIKI_Activity ");
    button.setToolTipText("Press this Button to go to SOCR 2D PointSegmentation EM Mixture Activity wiki page");
}

From source file:mupomat.view.PodrskaLozinka.java

private boolean kontrolaEmail() {
    pattern = Pattern.compile(Kontrola.EMAIL);
    matcher = pattern.matcher(txtEmail.getText().trim());

    Kontrola.resetirajPoljeGreske(txtEmail);
    if (!Kontrola.kontrolaPraznoPolje(txtEmail.getText(), txtEmail, "Niste unijeli email!", ikona)) {
        Kontrola.oznaciPoljeGreske(txtEmail);
        return false;
    }//from ww  w. j  ava2  s . c  o  m
    if (!matcher.matches()) {
        JOptionPane.showMessageDialog(rootPane,
                "Niste unijeli dobar format za email!\nPrimjer: korisnik@gmail.com", "Greka",
                JOptionPane.ERROR_MESSAGE);
        Kontrola.oznaciPoljeGreske(txtEmail);
        return false;
    }
    if (obradaKorisnik.provjeraEmaila(txtEmail.getText().trim())) {
        JOptionPane.showMessageDialog(rootPane, "Unijeli ste nepostojei e-mail!", "Greka",
                JOptionPane.ERROR_MESSAGE);
        Kontrola.oznaciPoljeGreske(txtEmail);
        return false;
    }

    return true;
}

From source file:com.yosanai.java.swing.editor.ObjectEditorTableModel.java

public void saveValues() {
    for (int index = 1; index < getRowCount(); index++) {
        String propertyName = getValueAt(index, 0).toString();
        String propertyValue = getValueAt(index, 1).toString();
        if (beanWrapper.isWritableProperty(propertyName)) {
            try {
                beanWrapper.setPropertyValue(propertyName, propertyValue);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e.getMessage(),
                        "Failed to set property value for " + propertyName, JOptionPane.ERROR_MESSAGE);
            }/* w ww  . j a v a  2 s. com*/
        }
    }
}

From source file:gda.gui.oemove.plugins.UndulatorControl.java

private void move() {
    try {//w w w  .  j a  v  a2s  .c  o m
        moveButton.setEnabled(false);
        double energy = Double.valueOf(energyField.getText());
        String command = "import org.jscience; import javax.swing.JOptionPane;umc = gda.factory.Finder.getInstance().find(\""
                + undulatorMediatorName + "\");";
        command = command + "umc.setRequestedHarmonic(org.jscience.physics.quantities.Quantity.valueOf("
                + harmonicCombo.getValue() + ", org.jscience.physics.units.Unit.ONE));";
        command = command + "umc.setRequestedPolarization(org.jscience.physics.quantities.Quantity.valueOf("
                + polarizationCombo.getValue() + ", org.jscience.physics.units.NonSI.DEGREE_ANGLE));";

        command = command + "\ntry:\n\tUndulatorEnergy.moveTo(gda.util.QuantityFactory.createFromString(\""
                + energy + " eV\"))";
        command = command + ";FixedFocus.moveTo(gda.util.QuantityFactory.createFromString(\"" + energy
                + " eV\"))" + "\n";
        command = command + "except gda.jython.scannable.ScannableException, se:";
        // Really should display the message from the Exception at this
        // point
        // but it is complicated because it has been added to by
        // UndulatorEnergy and Scannable and does not indicate the
        // likely
        // cause of the problem - that the requested move would move the
        // gap
        // or phase outside soft limits.
        command = command + "\n\tjavax.swing.JOptionPane.showMessageDialog(None,";
        command = command + " \"Move incomplete.\\nCheck requested move is within limits.\");";
        jsf.runCommand(command);
    } catch (NumberFormatException nfe) {
        JOptionPane.showMessageDialog(null, "Invalid energy specified", "", JOptionPane.ERROR_MESSAGE);
    }
}