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:de.rub.nds.burp.espresso.gui.UIOptions.java

/**
 * Load the configuration file and apply the configs to the UI. 
 * @param path The absolute path to the configuration file.
 *//*from www.ja  va2  s  .co m*/
private void loadConfig(String path) {
    File file = new File(path);
    if (!file.exists()) {
        JOptionPane.showMessageDialog(this, "The config file does not exist!", "File does not exist",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    if (!file.isDirectory() && file.canRead()) {
        JSONParser parser = new JSONParser();
        try {
            FileReader fr = new FileReader(file);
            JSONObject json_conf = (JSONObject) parser.parse(fr);

            openIDActive = (boolean) json_conf.get("OpenIDActive");
            openID1.setSelected(openIDActive);
            openIDConnectActive = (boolean) json_conf.get("OpenIDConnectActive");
            openIDConnect1.setSelected(openIDConnectActive);
            oAuthActive = (boolean) json_conf.get("OAuthActive");
            oAuth.setSelected(oAuthActive);
            facebookConnectActive = (boolean) json_conf.get("FacebookConnectActive");
            facebookConnect.setSelected(facebookConnectActive);
            browserIDActive = (boolean) json_conf.get("BrowserIDActive");
            browserID1.setSelected(browserIDActive);
            samlActive = (boolean) json_conf.get("SAMLActive");
            saml1.setSelected(samlActive);
            msAccountActive = (boolean) json_conf.get("MicrosoftAccountActive");
            msAccount.setSelected(msAccountActive);

            boolean asp = (boolean) json_conf.get("SSOActive");
            activeSSOProtocols.setSelected(asp);
            if (!asp) {
                oAuth.setEnabled(false);
                facebookConnect.setEnabled(false);
                saml1.setEnabled(false);
                openID1.setEnabled(false);
                openIDConnect1.setEnabled(false);
                browserID1.setEnabled(false);
                msAccount.setEnabled(false);
            }

            highlightBool = (boolean) json_conf.get("HighlightActive");
            highlightSSO.setSelected(highlightBool);

            String str = (String) json_conf.get("Schema");
            schemaText1.setText(str);
            str = (String) json_conf.get("Certificate");
            certText1.setText(str);
            str = (String) json_conf.get("Private Key");
            privKeyText1.setText(str);
            str = (String) json_conf.get("Public Key");
            pubKeyText1.setText(str);

            str = (String) json_conf.get("Input Script");
            scriptInText1.setText(str);
            str = (String) json_conf.get("Output Script");
            scriptOutText1.setText(str);

            str = (String) json_conf.get("Libraries");
            libText1.setText(str);

            str = (String) json_conf.get("Config");

            LoggingLevel = ((Long) json_conf.get("LogLvl")).intValue();
            logginglvlComboBox.setSelectedIndex(LoggingLevel);

            //                JOptionPane.showMessageDialog(this,
            //                            "The config from "+str+" is imported.",
            //                            "Import successfull",
            //                            JOptionPane.INFORMATION_MESSAGE);
            //                
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Can not read the config file!\n\nError:\n" + ex.toString(),
                    "Can not read config file", JOptionPane.ERROR_MESSAGE);
            Logging.getInstance().log(getClass(), ex);
        } catch (ParseException ex) {
            JOptionPane.showMessageDialog(this, "The content can not be parsed!\n\nError:\n" + ex.toString(),
                    "JSON Parsing Error", JOptionPane.ERROR_MESSAGE);
            Logging.getInstance().log(getClass(), ex);
        } catch (Exception ex) {
            Logging.getInstance().log(getClass(), ex);
        }

    } else {
        JOptionPane.showMessageDialog(this, "The file:\n" + path + "\n is not readable or directory.",
                "File not Found!", JOptionPane.ERROR_MESSAGE);
        Logging.getInstance().log(getClass(), "The file:\n" + path + "\n is not readable or directory.",
                Logging.ERROR);
    }
    saveConfig(path);
    Logging.getInstance().log(getClass(), "The config from " + path + " is now loaded.", Logging.INFO);
}

From source file:com.emental.mindraider.ui.dialogs.AddLinkToConceptJDialog.java

/**
 * Create a triplet./*from  w  w  w  . java  2s. c o  m*/
 */
protected void createTriplet() {
    if (StringUtils.isEmpty(predicateNs.getText())) {
        predicateNs.setText(MindRaiderConstants.MR_RDF_NS);
    }

    if (StringUtils.isEmpty(predicateLocalName.getText())) {
        predicateLocalName.setText(MindRaiderConstants.MR_RDF_PREDICATE);
    }

    if (StringUtils.isEmpty(objectNs.getText())) {
        objectNs.setText(MindRaiderConstants.MR_RDF_NS);
    }

    if (StringUtils.isEmpty(findConceptButton.getText())) {
        JOptionPane.showMessageDialog(MindRaider.mainJFrame, "You must specify object name.",
                "Statement Creation Error", JOptionPane.ERROR_MESSAGE);
        return;
    }

    MindRaider.spidersGraph.createStatement(new QName(predicateNs.getText(), predicateLocalName.getText()),
            new QName(null, objectNs.getText()), false);
    AddLinkToConceptJDialog.this.dispose();
}

From source file:flow.visibility.tapping.OpenDaylightHelper.java

public static void main(String ODPURL, String ODPAccount, String ODPPassword, String DPID, String Flow,
        String Priority, String Ingress, String Outgress, String Filter1, String Filter2, String Filter3,
        String Filter4, String Filter5, String Filter6) throws JSONException {
    //OpenDaylight Data
    //String ODPURL = "103.22.221.152:8080";
    //String ODPAccount = "admin";
    //String ODPPassword = "admin";

    /**Sample post data (refer to ODP REST API) */

    JSONObject postData = new JSONObject();
    postData.put("installInHw", "true");
    postData.put("name", Flow);
    postData.put("ingressPort", Ingress);
    postData.put("priority", Priority);
    postData.put("etherType", "0x800");

    //postData.put("nwSrc", Filter1);
    if (!Filter1.equals("")) {
        postData.put("nwSrc", Filter1);
    }/*from w ww .  j  ava2 s.  com*/

    //postData.put("nwDst", Filter2);
    if (!Filter2.equals("")) {
        postData.put("nwDst", Filter2);
    }

    if (!Filter3.equals("")) {
        postData.put("protocol", Filter3);
    }
    if (!Filter4.equals("")) {
        postData.put("tpSrc", Filter4);
    }
    if (!Filter5.equals("")) {
        postData.put("tpDst", Filter5);
    }
    if (!Filter6.equals("")) {
        postData.put("vlanId", Filter6);
    }

    /** Make string for OpenFlow Action */
    String Action = "OUTPUT=" + Outgress;
    postData.put("actions", new JSONArray().put(Action));

    /** Select Node on which this flow should be installed */
    JSONObject node = new JSONObject();
    node.put("id", DPID);
    node.put("type", "OF");
    postData.put("node", node);

    /** Actual flow installation */
    boolean result = OpenDaylightHelper.installFlow(postData, ODPAccount, ODPPassword, ODPURL);

    /** The Result of the Flow Installation */

    if (result) {
        System.out.println("Flow installed Successfully");
        JOptionPane.showMessageDialog(null, "Flow installed Successfully.", "Successful Message",
                JOptionPane.PLAIN_MESSAGE);
    } else {
        System.err.println("Failed to install flow!");
        JOptionPane.showMessageDialog(null, "Failed to install flow!", "Error Message",
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:de.badw.strauss.glyphpicker.controller.alltab.TeiLoadWorker.java

/**
 * Loads TEI data from a URL.//w  w w. j a va2 s  .  c om
 *
 * @return the resulting GlyphDefinition list
 */
public List<GlyphDefinition> loadDataFromUrl() {
    SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
    try {
        HttpGet httpGet = new HttpGet(dataSource.getBasePath());
        return httpClient.execute(httpGet, new XMLResponseHandler());
    } catch (IOException e) {
        String message = String.format(i18n.getString("TeiLoadWorker.couldNotLoadData"),
                e.getLocalizedMessage(), dataSource.getBasePath());
        if (e instanceof UnknownHostException) {
            message += " Unknown host";
        }
        JOptionPane.showMessageDialog(null, message, i18n.getString("TeiLoadWorker.error"),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.info(e);
    } finally {
        httpClient.getConnectionManager().shutdown();
    }

    return null;
}

From source file:de.huberlin.cuneiform.compiler.debug.DebugDispatcher.java

@Override
public void actionPerformed(ActionEvent e) {

    List<Integer> signatureList;
    Set<Invocation> readyInvocationSet;
    Set<JsonReportEntry> report;

    if (e.getSource() == exitItem) {

        frame.dispose();/*from   ww  w.j ava2  s .c om*/
        return;
    }

    if (e.getActionCommand().equals(PreInvocView.LABEL_STEP)) {

        signatureList = invocOverview.getSelectedPreInvocSignatureList();
        readyInvocationSet = getReadyInvocationSet();

        if (signatureList == null)
            throw new NullPointerException("Signature list must not be null.");

        if (signatureList.isEmpty())
            throw new RuntimeException("Signature list must not be empty.");

        invocOverview.setContentOld();

        try {

            for (Integer i : signatureList) {

                if (i == null)
                    throw new NullPointerException("Signature must not be null.");

                for (Invocation invoc : readyInvocationSet)

                    if (invoc.getSignature() == i) {

                        report = dispatch(invoc);

                        if (!invoc.isComputed())
                            throw new RuntimeException("Expected the invocation to be computed.");

                        evalReport(report);

                        readyInvocationSet.remove(invoc);

                        invocOverview.removePreInvocation(invoc);
                        invocOverview.insertPostInvocation(invoc);

                        break;
                    }

                updateView();
            }
        } catch (NotDerivableException e1) {

            e1.printStackTrace();

            JOptionPane.showMessageDialog(frame, e1.getMessage(), "NotDerivableException",
                    JOptionPane.ERROR_MESSAGE);

        } catch (IOException e1) {

            e1.printStackTrace();

            JOptionPane.showMessageDialog(frame, e1.getMessage(), "IOException", JOptionPane.ERROR_MESSAGE);

        } catch (InterruptedException e1) {

            e1.printStackTrace();

            JOptionPane.showMessageDialog(frame, e1.getMessage(), "InterruptedException",
                    JOptionPane.ERROR_MESSAGE);

        } catch (JSONException e1) {

            e1.printStackTrace();

            JOptionPane.showMessageDialog(frame, e1.getMessage(), "JSONException", JOptionPane.ERROR_MESSAGE);
        }

        return;
    }
}

From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsResultsPanel.java

@Override
public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    Object source = e.getSource();
    if (source == enlargeButton) {
        enlargeChart();/*from  w w w  .j  a va 2  s.c  om*/
    } else if (source == saveChartButton) {
        SaveChartDialog dialog = new SaveChartDialog(cyActivator.getCySwingAppication().getJFrame(),
                timeSeries);
        dialog.setVisible(true);
    } else if (source == saveDataButton) {
        saveData();
    } else if (source == closeTabButton) {
        cyActivator.getCyServiceRegistrar().unregisterService(this, CytoPanelComponent.class);
    } else if (source == helpButton) {
        try {
            java.awt.Desktop.getDesktop()
                    .browse(java.net.URI.create("https://code.google.com/p/dynnetwork/wiki/DynNetworkHelp"));
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error connecting to help!", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        //Improve  the documentation
        //DynamicNetworkHelp help = new DynamicNetworkHelp();
        //help.displayHelp();
    }
}

From source file:com.emr.schemas.DestinationTables.java

/**
 * Method for getting the MPI database's tables
 *///from  w  ww  . ja v a 2 s .co  m
public final void getDatabaseMetaData() {
    try {

        DatabaseMetaData dbmd = mpiConn.getMetaData();
        String[] types = { "TABLE" };
        ResultSet rs = dbmd.getTables(null, null, "%", types);
        while (rs.next()) {
            //Add table name to Jlist
            listModel.addElement(rs.getString("TABLE_NAME"));
        }
    } catch (SQLException e) {
        String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e);
        JOptionPane.showMessageDialog(this,
                "Could not fetch Tables for the KenyaEMR Database. Error Details: " + stacktrace,
                "Table Names Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:biomine.bmvis2.Vis.java

private void openURL(String url) {
    if (url == null)
        return;/*w w w . j ava 2  s  .c  o m*/
    if (appletContext != null) {
        try {
            appletContext.showDocument(new URL(url), "_blank");
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Failed to open URL: " + url + "\n" + e.getMessage(),
                    "Error opening URL", JOptionPane.ERROR_MESSAGE);
        }
        return;
    }
    String os = System.getProperty("os.name");
    if (os.startsWith("Mac OS")) {
        try {
            Class fileMgr = Class.forName("com.apple.eio.FileManager");
            Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
            if (openURL != null)
                openURL.invoke(null);
        } catch (Exception e) {
            Logging.error("ui", "Error opening URL: " + e.getMessage());
        }
        return;
    }
    if (os.startsWith("Windows")) {
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
        } catch (Exception e) {
            Logging.error("ui", "Error opening URL: " + e.getMessage());
        }
        return;
    }
    // DEBUG: Assuming Firefox for everything not OS X or Windows
    try {
        Runtime.getRuntime().exec(new String[] { "firefox", "-remote", "openurl(" + url + ", new-tab)" });
    } catch (Exception e) {
        Logging.error("ui", "Error opening URL: " + e.getMessage());
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java

/**
 * Create the PDF report file./*  w w w  .  jav a2  s.c o m*/
 *
 * @param directory
 * @param reportName
 * @return the file created
 */
@Override
public File createAnalysisReport(File directory, String reportName) {
    this.experiment = doseResponseController.getExperiment();
    File pdfFile = new File(directory, reportName);
    if (reportName.endsWith(".pdf")) {
        tryToCreateFile(pdfFile);
    } else {
        doseResponseController.showMessage("Please use .pdf extension for the file.", "extension file problem",
                JOptionPane.WARNING_MESSAGE);
        // retry to create pdf file
        try {
            doseResponseController.createPdfReport();
        } catch (IOException ex) {
            LOG.error(ex.getMessage(), ex);
            doseResponseController.showMessage("An error occurred: " + ex.getMessage(), "unexpected error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    return pdfFile;
}

From source file:com.clough.android.adbv.view.UpdateTableDialog.java

private synchronized void processResult() {
    try {//from  w  w w .jav a2 s.c o  m
        final JSONArray jsonArray = new JSONArray(outputResult);
        final int jsonObjectLength = jsonArray.length();

        new SwingWorker<Void, Void>() {

            boolean columnsFound = false;

            @Override
            protected Void doInBackground() {
                rowList = new ArrayList<Row>();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ex) {
                }
                try {
                    for (int i = 0; i < jsonObjectLength; i++) {
                        waitingDialog.incrementProgressBar();
                        JSONObject jsonObject = jsonArray.getJSONObject(i);
                        Object[] rowData = new Object[defaultTableModel.getColumnCount()];
                        for (int j = 0; j < resultTable.getColumnCount(); j++) {
                            String cellValue = String.valueOf(jsonObject.get(resultTable.getColumnName(j)))
                                    .replaceAll("\n", "").replaceAll("\t", " ");
                            rowData[j] = cellValue;
                        }
                        defaultTableModel.addRow(rowData);
                        rowList.add(new Row(i, rowData, Row.DEFAULT));
                    }
                } catch (Exception e) {
                    return null;
                }
                return null;
            }

            @Override
            protected void done() {
                tableColumnAdjuster.adjustColumns();
                rowController = RowController.getPreparedRowController(rowList);
                closeProgressDialog();
                resultTable.setRowSelectionAllowed(false);
                rowsToChange = new ArrayList<Row>();
                rowsToChange.addAll(rowList);
            }

        }.execute();
        showProgressDialog(false, jsonObjectLength, "Processing " + jsonObjectLength + " fields");
    } catch (JSONException ex) {
        JOptionPane.showMessageDialog(null, outputResult, "Result error", JOptionPane.ERROR_MESSAGE);
    }
}