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:eu.apenet.dpt.standalone.gui.validation.DownloadReportActionListener.java

public void actionPerformed(ActionEvent e) {
    String defaultSaveLocation = dataPreparationToolGUI.getDefaultSaveLocation();
    File file = new File(defaultSaveLocation + "report.txt");
    try {//from   ww w  . j ava 2s.c o m
        FileInstance fileInstance = dataPreparationToolGUI.getFileInstances()
                .get(((File) dataPreparationToolGUI.getXmlEadList().getSelectedValue()).getName());
        FileUtils.writeStringToFile(file, getStringFromMap(fileInstance.getXmlQualityErrors()));
        JOptionPane.showMessageDialog(dataPreparationToolGUI.getContentPane(),
                MessageFormat.format(dataPreparationToolGUI.getLabels().getString("dataquality.reportSaved"),
                        defaultSaveLocation),
                dataPreparationToolGUI.getLabels().getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE,
                Utilities.icon);
    } catch (IOException e1) {
        LOG.error("Could not save the report.txt file", e1);
        JOptionPane.showMessageDialog(dataPreparationToolGUI.getContentPane(),
                dataPreparationToolGUI.getLabels().getString("dataquality.reportSavedError"),
                dataPreparationToolGUI.getLabels().getString("fileSaved"), JOptionPane.ERROR_MESSAGE,
                Utilities.icon);
    }
}

From source file:edu.wpi.cs.wpisuitetng.janeway.gui.login.LoginController.java

@Override
public void actionPerformed(ActionEvent e) {

    // Save the field values
    ConfigManager.getConfig().setUserName(view.getUserNameField().getText());
    ConfigManager.getConfig().setProjectName(view.getProjectField().getText());

    // Check the core URL and display the main application window
    if (view.getUrlTextField().getText().length() > 0) { // ensure the URL field has content
        final String URLText = view.getUrlTextField().getText();
        final URL coreURL;
        try { // try to convert the URL text to a URL object
            coreURL = new URL(URLText);
            ConfigManager.getConfig().setCoreUrl(coreURL);
            ConfigManager.writeConfig();
            Network.getInstance().setDefaultNetworkConfiguration(new NetworkConfiguration(URLText));

            // Send the request
            sendLoginRequest();// ww  w.  j av  a 2 s .  co m

        } catch (MalformedURLException e1) { // failed, bad URL
            JOptionPane.showMessageDialog(view, "The server address \"" + URLText + "\" is not a valid URL!",
                    errorTitle, JOptionPane.ERROR_MESSAGE);
        }
    } else { // a URL was not entered
        JOptionPane.showMessageDialog(view, "You must specify the server address!", errorTitle,
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:net.mohatu.bloocoin.miner.RegCustom.java

private void register() {
    try {/*from www.  ja  va 2  s. c  om*/
        String result = new String();
        Socket sock = new Socket(this.url, this.port);
        String command = "{\"cmd\":\"register" + "\",\"addr\":\"" + addr + "\",\"pwd\":\"" + key + "\"}";
        DataInputStream is = new DataInputStream(sock.getInputStream());
        DataOutputStream os = new DataOutputStream(sock.getOutputStream());
        os.write(command.getBytes());
        os.flush();

        BufferedReader in = new BufferedReader(new InputStreamReader(is));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            result += inputLine;
        }

        is.close();
        os.close();
        sock.close();
        System.out.println(result);
        if (result.contains("\"success\": true")) {
            System.out.println("Registration successful: " + addr);
            saveBloostamp();
        } else if (result.contains("\"success\": false")) {
            System.out.println("Result: Failed");
            JOptionPane.showMessageDialog(Main.scrollPane,
                    "Registration failed.\nCheck your network connection", "Registration Failed",
                    JOptionPane.ERROR_MESSAGE);
            System.exit(0);
        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ExecDemoNS.java

public void doWait() {
    if (pStack.size() == 0)
        return;/*from  w ww  .ja  v  a 2s .  c  om*/
    try {
        pStack.peek().waitFor();
        // wait for process to complete (does not work as expected for Windows programs)
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "Error" + ex, "Error", JOptionPane.ERROR_MESSAGE);
    }
    pStack.pop();
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static XYSeriesCollection getXYSeriesCollection(String chartName, DBSeerDataSet dataset)
        throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval("[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");

    timestamp = runner.getVariableDouble("timestamp");

    XYSeriesCollection XYdataSet = new XYSeriesCollection();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        System.out.println(numXCellArray + " : " + numYCellArray);
        return null;
    }/*from   ww w  .  j a v a2s .  co  m*/

    java.util.List<String> transactionNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numLegends; ++i) {
        String legend = (String) legends[i];
        for (int j = 0; j < transactionNames.size(); ++j) {
            if (legend.contains("Type " + (j + 1))) {
                legends[i] = legend.replace("Type " + (j + 1), transactionNames.get(j));
                break;
            }
        }
    }

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        int row = 0, col = 0;
        int xLength = 0;

        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        xLength = xArray.length;
        row = (int) yArraySize[0];
        col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            XYSeries series;
            String legend = "";
            int legendIdx = (dataCount >= numLegends) ? numLegends - 1 : dataCount;
            if (legendIdx >= 0) {
                legend = (String) legends[legendIdx];
            }
            if (numLegends == 0) {
                series = new XYSeries("Data " + dataCount + 1);
            } else if (dataCount >= numLegends) {
                series = new XYSeries(legend + (dataCount + 1));
            } else {
                series = new XYSeries(legend);
            }

            for (int r = 0; r < row; ++r) {
                int xRow = (r >= xLength) ? xLength - 1 : r;
                double yValue = yArray[r + c * row];
                // remove negatives
                if (yValue < 0) {
                    yValue = 0;
                }
                series.add(xArray[xRow], yValue);
            }
            XYdataSet.addSeries(series);
            ++dataCount;
        }
    }

    return XYdataSet;
}

From source file:biz.wolschon.finance.jgnucash.actions.SaveAsFilePluginMenuAction.java

@Override
public void actionPerformed(final ActionEvent e) {
    try {/*ww  w.j  ava  2  s . c  o m*/

        // Activate plug-in that declares extension.
        myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId());
        // Get plug-in class loader.
        ClassLoader classLoader = myJGnucashEditor.getPluginManager()
                .getPluginClassLoader(ext.getDeclaringPluginDescriptor());
        // Load Tool class.
        Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString());
        // Create Tool instance.
        Object o = toolCls.newInstance();
        if (!(o instanceof DataSourcePlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        DataSourcePlugin importer = (DataSourcePlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //workaround because of a deadlock in log4j-consoleAppender in the JPf-classloader
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").removeAllAppenders();
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").setLevel(Level.FATAL);
            importer.writeTo(myJGnucashEditor.getWritableModel());
        } catch (Exception e1) {
            LOGGER.error("Write via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Write via Plugin '" + pluginName + "' failed.\n" + "["
                                    + e1.getClass().getName() + "]: " + e1.getMessage(),
                            JOptionPane.ERROR_MESSAGE);
        } finally {
            myJGnucashEditor.setCursor(Cursor.getDefaultCursor());
        }
    } catch (Exception e1) {
        LOGGER.error("Could not activate requested Writer-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested Writer-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

From source file:EditorPaneExample3.java

public EditorPaneExample3() {
    super("JEditorPane Example 3");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//from w  w  w .j a va2 s  .  c o m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();
            try {
                // Try to display the page
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setPage(url);

                loadingState.setText("Loaded");
                loadedType.setText(pane.getContentType());
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
            }
        }
    });
}

From source file:fi.smaa.jsmaa.gui.components.ValueFunctionMouseListener.java

@Override
public void chartMouseClicked(ChartMouseEvent ev) {
    ChartEntity ent = ev.getEntity();//from  w w w . j  av  a 2 s.c o m

    if (ent instanceof XYItemEntity) {
        XYItemEntity xyItemEntity = (XYItemEntity) ent;
        int idx = xyItemEntity.getItem();
        if (idx > 0 && idx < (crit.getValuePoints().size() - 1)) {
            crit.deleteValuePoint(idx);
        }
    } else if (ent instanceof PlotEntity) { // add a new point
        double realX = getRealX(ev);
        double realY = getRealY(ev);
        try {
            crit.addValuePoint(new Point2D(realX, realY));
        } catch (InvalidValuePointException e) {
            JOptionPane.showMessageDialog(parent,
                    "Cannot add partial value function segments: " + e.getMessage(),
                    "Unable to add point to the partial value function", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:biz.wolschon.finance.jgnucash.actions.OpenFilePluginMenuAction.java

@Override
public void actionPerformed(final ActionEvent e) {
    try {//w w  w.  jav a 2s .c om

        // Activate plug-in that declares extension.
        myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId());
        // Get plug-in class loader.
        ClassLoader classLoader = myJGnucashEditor.getPluginManager()
                .getPluginClassLoader(ext.getDeclaringPluginDescriptor());
        // Load Tool class.
        Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString());
        // Create Tool instance.
        Object o = toolCls.newInstance();
        if (!(o instanceof DataSourcePlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        DataSourcePlugin importer = (DataSourcePlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //workaround because of a deadlock in log4j-consoleAppender in the JPf-classloader
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").removeAllAppenders();
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").setLevel(Level.FATAL);
            GnucashWritableFile loadedFile = importer.loadFile();
            if (loadedFile != null) {
                myJGnucashEditor.setWritableModel(loadedFile);
            }
        } catch (Exception e1) {
            LOGGER.error("Load via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Load via Plugin '" + pluginName + "' failed.\n" + "["
                                    + e1.getClass().getName() + "]: " + e1.getMessage(),
                            JOptionPane.ERROR_MESSAGE);
        } finally {
            myJGnucashEditor.setCursor(Cursor.getDefaultCursor());
        }
    } catch (Exception e1) {
        LOGGER.error("Could not activate requested Loader-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested Loader-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

From source file:edu.ku.brc.helpers.XMLHelper.java

/**
    * Reads a File and return the root element from the DOM
    * @param file the file to be read/*from www.  j a  v  a2s  .c  o m*/
    */
public static org.dom4j.Element readFileToDOM4J(final File file) throws Exception {
    if (useChecksum && configDir != null && !file.getName().equals("checksum.ini") && //$NON-NLS-1$
            !XMLChecksumUtil.checkSignature(file)) {
        JOptionPane.showMessageDialog(null, getResourceString("XMLHelper.CHECKSUM_MSG"), //$NON-NLS-1$
                getResourceString("XMLHelper.CHECKSUM_TITLE"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
        System.exit(0);
    }

    if (!file.exists()) {
        //log.error("the file ["+file+"] doesn't exist."); //$NON-NLS-1$ //$NON-NLS-2$
        return null;
    }

    return readFileToDOM4J(new FileInputStream(file));
}