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:net.mumie.coursecreator.xml.GraphXMLizer.java

/**
 * Describe <code>doTransform</code> method here.
 *
 * @param document a <code>Node</code> value
 * @return a <code>ByteArrayOutputStream</code> value
 * @exception TransformerException if an error occurs
 * @exception UnsupportedEncodingException if an error occurs
 *//* w  w  w .jav a 2 s  .  c  o  m*/
private static ByteArrayOutputStream doTransform(Node document)
        throws TransformerException, UnsupportedEncodingException {
    try {

        // Use a Transformer for output
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty(OutputKeys.ENCODING, "US-ASCII");

        DOMSource source = new DOMSource(document);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamWriter out = new OutputStreamWriter(baos, "ASCII");
        StreamResult result = new StreamResult(out);
        transformer.transform(source, result);

        return baos;

    } catch (TransformerException te) {
        // Error generated by the parser
        CCController.dialogErrorOccured("GraphXMLizer: TransformerException",
                "GraphXMLizer: TransformerException: " + te, JOptionPane.ERROR_MESSAGE);

        throw te;
    }
}

From source file:net.sf.jabref.external.DownloadExternalFile.java

/**
 * Start a download./*from  w w  w . j  a  v  a 2  s  .co  m*/
 *
 * @param callback The object to which the filename should be reported when download
 *                 is complete.
 */
public void download(final DownloadCallback callback) throws IOException {
    dontShowDialog = false;
    final String res = JOptionPane.showInputDialog(frame, Localization.lang("Enter URL to download"));

    if ((res == null) || res.trim().isEmpty()) {
        return;
    }

    URL url;
    try {
        url = new URL(res);
    } catch (MalformedURLException ex1) {
        JOptionPane.showMessageDialog(frame, Localization.lang("Invalid URL"),
                Localization.lang("Download file"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    download(url, callback);
}

From source file:agendapoo.View.FrmCadastroAtividade.java

private void cadastrarAtividade(Usuario loggedUser) {
    ControlUsuario control = new ControlUsuario();
    try {//from www.j  a va 2 s.  c  om
        cadastraAtividade(textDescricao.getText(), textLocal.getText(), textData.getText(),
                textTimeInicio.getText(), textTimeFinal.getText(),
                comboTipoAtividade.getSelectedItem().toString());
        JOptionPane.showMessageDialog(null, "Atividade cadastrada com sucesso! :)");
        usuarioMain.loadAtividades();
        this.dispose();
    } catch (SQLException | IOException | InvalidTimeRangeException | TimeInterferenceException
            | ClassNotFoundException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (DateTimeParseException dtpe) {
        JOptionPane.showMessageDialog(this, "Por favor, insira uma hora vlida!", "Hora invlida.",
                JOptionPane.ERROR_MESSAGE);
    } catch (EmailException ex) {
        JOptionPane.showMessageDialog(this,
                "No foi possvel enviar e-mail para os convidados cadastrados,"
                        + "por favor, verifique sua conexo com a internet e tente novamente.",
                "Erro ao enviar e-mail", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:v800_trainer.JUebersicht.java

/** Creates new JUebersicht */
public JUebersicht(JCicloTronic JTronicHandle) {

    int AnzahlJahre = JTronicHandle.Auswahl_bersicht.getItemCount();
    int i, j;/*from w  w  w  .  jav  a 2 s.  com*/

    padding = new RectangleInsets(0, 50 * (int) JTronicHandle.FontSize / 12, 0,
            40 * (int) JTronicHandle.FontSize / 12);

    String dummy;
    String Jahr;
    String Filename;
    Kalender = new GregorianCalendar(1900, 1, 1);

    HmJahr = new float[AnzahlJahre + 1][367]; //ein Index mehr fr die 12 Monate bersicht des ersten Jahres
    kmJahr = new float[AnzahlJahre + 1][367];
    Zeit = new float[AnzahlJahre + 1][367];

    DataProperty = new java.util.Properties();
    try {
        for (i = 0; i < JTronicHandle.Datentabelle.getRowCount(); i++) {

            Filename = (String) JTronicHandle.sorter.getValueAt(i, 5) + ".cfg";

            try {
                FileInputStream in = new FileInputStream(Filename);
                DataProperty.load(in);
                in.close();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "JUebersicht\nIO-Fehler bei " + Filename + e, "Achtung!",
                        JOptionPane.ERROR_MESSAGE);
            }
            try {
                Kalender = new GregorianCalendar(Integer.parseInt(DataProperty.getProperty("Jahr", "0")),
                        Integer.parseInt(DataProperty.getProperty("Monat", "0")) - 1,
                        Integer.parseInt(DataProperty.getProperty("Tag", "0")));

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "JUebersicht\nException GregorianCalender  " + e,
                        "Achtung!", JOptionPane.ERROR_MESSAGE);

            }

            for (j = 0; j < JTronicHandle.Auswahl_bersicht.getItemCount(); j++) {
                if (JTronicHandle.Auswahl_bersicht.getItemAt(j).toString()
                        .equals(DataProperty.getProperty("Jahr", "0"))) {

                    break;
                }
            }

            HmJahr[j][Kalender.get(Kalender.DAY_OF_YEAR)] += Float
                    .parseFloat(DataProperty.getProperty("Hoehenmeter", "0"));
            kmJahr[j][Kalender.get(Kalender.DAY_OF_YEAR)] += Float
                    .parseFloat(DataProperty.getProperty("Strecke", "0").replace(',', '.'));
            Zeit[j][Kalender.get(Kalender.DAY_OF_YEAR)] += Float
                    .parseFloat(DataProperty.getProperty("Dauer", "0")) / 3600.0;

        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "JUebersicht (Dateninitialisierung)\nException +" + e, "Achtung!",
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:net.sf.housekeeper.swing.MainFrame.java

/**
 * Displays this main frame.//from  ww  w  .ja v  a2  s. co  m
 */
public void show() {
    view.show();
    try {
        PersistenceController.instance().replaceDomainWithSaved();
    } catch (IOException e1) {
        //Nothing wrong about that
    } catch (UnsupportedFileVersionException e1) {
        LOG.error("Unsupported file format: " + e1.getVersion(), e1);
        final String error = LocalisationManager.INSTANCE.getText("gui.error");
        JOptionPane.showMessageDialog(view, e1.getLocalizedMessage(), error, JOptionPane.ERROR_MESSAGE);
    }
}

From source file:EditorPaneExample4.java

public EditorPaneExample4() {
    super("JEditorPane Example 4");

    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;/*  w w w .  j a  va  2s .co  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 {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                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);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");
                textField.setEnabled(true); // Allow entry of new URL
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });
}

From source file:net.sf.jabref.gui.entryeditor.SimpleUrlDragDrop.java

@Override
public void drop(DropTargetDropEvent event) {
    Transferable tsf = event.getTransferable();
    event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    //try with an URL
    DataFlavor dataFlavor = null;
    try {/*w ww .  j  a  v  a 2  s  .  c o m*/
        dataFlavor = new DataFlavor("application/x-java-url; class=java.net.URL");
    } catch (ClassNotFoundException e) {
        LOGGER.warn("Could not find DropTargetDropEvent class", e);
    }
    try {
        URL url = (URL) tsf.getTransferData(dataFlavor);
        //insert URL
        editor.setText(url.toString());
        storeFieldAction.actionPerformed(new ActionEvent(editor, 0, ""));
    } catch (UnsupportedFlavorException nfe) {
        // if not an URL
        JOptionPane.showMessageDialog((Component) editor, Localization.lang("Operation not supported"),
                Localization.lang("Drag and Drop Error"), JOptionPane.ERROR_MESSAGE);
        LOGGER.warn("Could not perform drage and drop", nfe);
    } catch (IOException ioex) {
        LOGGER.warn("Could not perform drage and drop", ioex);
    }
}

From source file:Formulario.CapturaHuella.java

public CapturaHuella() {
    try {/*from   w w  w  .j a  v a2 s .co  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Imposible modificar el tema visual", "Lookandfeel invlido.",
                JOptionPane.ERROR_MESSAGE);
    }
    initComponents(); //Carga los componentes del JPanel

    txtArea.setEditable(false);
    //agreagr logo y nombre en la barra superior

    setIconImage(new ImageIcon(getClass().getResource("/img/logoCrecic.jpg")).getImage());
    setTitle("Crecic S.A");

}

From source file:net.itransformers.topologyviewer.menu.handlers.graphTools.searchMenuHandlers.SearchByIpMenuHandler.java

@Override
public void actionPerformed(ActionEvent e) {

    //                Map<String, Map<String, GraphMLMetadata<G>>> test1 = graphmlLoader();

    //        String key = JOptionPane.showInputDialog(frame, "Choose IP", JOptionPane.QUESTION_MESSAGE);
    final String ip = JOptionPane.showInputDialog(frame, "Enter IP", "Value", JOptionPane.QUESTION_MESSAGE);

    GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
    Set<String> foundVertexes;
    foundVertexes = viewerPanel.FindNodeByKey("RoutePrefixes", new Object() {
        @Override// w w  w .  j av  a2  s.  com
        public boolean equals(Object obj) {
            String s = (String) obj;
            String[] ipRanges = s.split(",");
            for (String ipRangeNotTrimmed : ipRanges) {
                String ipRange = ipRangeNotTrimmed.trim();
                if (ipRange.equals("") || ipRange.equals("0.0.0.0/0"))
                    continue;
                try {
                    SubnetUtils subnet = new SubnetUtils(ipRange);
                    if (subnet.getInfo().isInRange(ip)) {
                        return true;
                    }
                } catch (IllegalArgumentException iae) {
                    logger.error("Can not parse ip or ip range:" + ipRange + ", ip:" + ip);
                    System.out.println("Can not parse ip or ip range:" + ipRange + ", ip:" + ip);
                    iae.printStackTrace();
                    continue;
                }
            }
            return false;
        }
    });
    if (!foundVertexes.isEmpty()) {
        Iterator it = foundVertexes.iterator();
        if (foundVertexes.size() == 1) {
            Object element = it.next();
            System.out.println("Redrawing around " + element.toString());
            viewerPanel.SetPickedState(element.toString());
            viewerPanel.Animator(element.toString());
        } else {
            JOptionPane.showMessageDialog(frame, "Multiple Nodes with ip " + ip + " found :\n" + foundVertexes,
                    "Error", JOptionPane.ERROR_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(frame, "Can not find node with ip " + ip, "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:cpsControllers.ConversionController.java

/**
 * Bd redniokwadratowy (MSE, ang. <i>Mean Squared Error</i>)
 *     /*from   www .j  a va2  s  .c o m*/
 * @param punktyY
 * @param _doPorownania
 *     
* @return
 */
public double obl_MSE(ArrayList<Double> punktyY, ArrayList<Double> _doPorownania) {
    double wynik = 0;
    try {
        if (!punktyY.isEmpty() && !_doPorownania.isEmpty()) {
            for (int i = 0; i < _doPorownania.size(); i++) {
                wynik = wynik
                        + (punktyY.get(i) - _doPorownania.get(i)) * (punktyY.get(i) - _doPorownania.get(i));
            }
            wynik = (1.0D / _doPorownania.size()) * wynik;
        } else {
            if (punktyY.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak sygnau.", "Bd", JOptionPane.ERROR_MESSAGE);
            } else if (_doPorownania.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak konwersji sygnau.", "Bd",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } catch (Exception exc_MSE) {
        //            JOptionPane.showMessageDialog(null, "Nie mona obliczy:\n" + exc_MSE.getMessage(),
        //                    "Bd", JOptionPane.ERROR_MESSAGE);
    }

    System.out.println("MSE = " + wynik);
    return wynik;
}