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:ch.admin.hermes.etl.load.HermesOnlineCrawler.java

/**
 * Liefert alle Szenarion URL's //from  w w  w  .ja v  a 2  s. co m
 * @return 
 * @throws Exception Allgemeiner I/O Fehler
 */
public String[] getScenarios() throws Exception {
    ArrayList<String> s = new ArrayList<String>();
    HttpGet get = new HttpGet(url + scenarios);

    try {
        HttpResponse response = httpClient.execute(get);

        HttpEntity entity = response.getEntity();
        String pageHTML = EntityUtils.toString(entity);
        EntityUtils.consume(entity);

        Document document = Jsoup.parse(pageHTML);
        Elements elements = document.getElementsByAttribute("href");
        for (Element e : elements) {
            if (e.attr("href").startsWith("/szenarien")) {
                String attr = e.attr("href").substring(scenario_prefix.length());
                attr = attr.substring(0, attr.lastIndexOf('/'));
                s.add(attr);
            }
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null,
                "Keine Online Verbindung mglich. Bitte Szenario manuell downloaden, entpacken und bei XMl Model eintragen.",
                "Keine Verbindung zu http://www.hermes.admin.ch", JOptionPane.WARNING_MESSAGE);

    }
    return (s.toArray(new String[s.size()]));
}

From source file:StocksTable5.java

public void retrieveData() {
    SimpleDateFormat frm = new SimpleDateFormat("MM/dd/yyyy");
    String currentDate = frm.format(m_data.m_date);
    String result = (String) JOptionPane.showInputDialog(this, "Please enter date in form mm/dd/yyyy:", "Input",
            JOptionPane.INFORMATION_MESSAGE, null, null, currentDate);
    if (result == null)
        return;//from   w ww.j  a  va2s . co m

    java.util.Date date = null;
    try {
        date = frm.parse(result);
    } catch (java.text.ParseException ex) {
        date = null;
    }

    if (date == null) {
        JOptionPane.showMessageDialog(this, result + " is not a valid date", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    switch (m_data.retrieveData(date)) {
    case 0: // Ok with data
        m_title.setText(m_data.getTitle());
        m_table.tableChanged(new TableModelEvent(m_data));
        m_table.repaint();
        break;
    case 1: // No data
        JOptionPane.showMessageDialog(this, "No data found for " + result, "Warning",
                JOptionPane.WARNING_MESSAGE);
        break;
    case -1: // Error
        JOptionPane.showMessageDialog(this, "Error retrieving data", "Warning", JOptionPane.WARNING_MESSAGE);
        break;
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairPublicKeyAction.java

/**
 * Do action./*from  w  w w. j  av a2 s  .  c  om*/
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        String alias = kseFrame.getSelectedEntryAlias();

        DExportPublicKeyOpenSsl dExportPublicKey = new DExportPublicKeyOpenSsl(frame, alias);
        dExportPublicKey.setLocationRelativeTo(frame);
        dExportPublicKey.setVisible(true);

        if (!dExportPublicKey.exportSelected()) {
            return;
        }

        exportFile = dExportPublicKey.getExportFile();
        boolean pemEncode = dExportPublicKey.pemEncode();

        PublicKey publicKey = getPublicKey(alias);

        byte[] encoded = null;

        if (pemEncode) {
            encoded = OpenSslPubUtil.getPem(publicKey).getBytes();
        } else {
            encoded = OpenSslPubUtil.get(publicKey);
        }

        exportEncodedPublicKey(encoded, exportFile);

        JOptionPane.showMessageDialog(frame,
                res.getString("ExportKeyPairPublicKeyAction.ExportPublicKeyOpenSslSuccessful.message"),
                res.getString("ExportKeyPairPublicKeyAction.ExportPublicKeyOpenSsl.Title"),
                JOptionPane.INFORMATION_MESSAGE);
    } catch (FileNotFoundException ex) {
        String message = MessageFormat.format(res.getString("ExportKeyPairPublicKeyAction.NoWriteFile.message"),
                exportFile);

        JOptionPane.showMessageDialog(frame, message,
                res.getString("ExportKeyPairPublicKeyAction.ExportPublicKeyOpenSsl.Title"),
                JOptionPane.WARNING_MESSAGE);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}

From source file:net.sf.keystore_explorer.gui.actions.ExportTrustedCertificatePublicKeyAction.java

/**
 * Do action.//from  w  w w.j  a v a 2s . c o  m
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        String alias = kseFrame.getSelectedEntryAlias();

        DExportPublicKeyOpenSsl dExportPublicKey = new DExportPublicKeyOpenSsl(frame, alias);
        dExportPublicKey.setLocationRelativeTo(frame);
        dExportPublicKey.setVisible(true);

        if (!dExportPublicKey.exportSelected()) {
            return;
        }

        exportFile = dExportPublicKey.getExportFile();
        boolean pemEncode = dExportPublicKey.pemEncode();

        PublicKey publicKey = getPublicKey(alias);

        byte[] encoded = null;

        if (pemEncode) {
            encoded = OpenSslPubUtil.getPem(publicKey).getBytes();
        } else {
            encoded = OpenSslPubUtil.get(publicKey);
        }

        exportEncodedPublicKey(encoded, exportFile);

        JOptionPane.showMessageDialog(frame,
                res.getString(
                        "ExportTrustedCertificatePublicKeyAction.ExportPublicKeyOpenSslSuccessful.message"),
                res.getString("ExportTrustedCertificatePublicKeyAction.ExportPublicKeyOpenSsl.Title"),
                JOptionPane.INFORMATION_MESSAGE);
    } catch (FileNotFoundException ex) {
        String message = MessageFormat.format(
                res.getString("ExportTrustedCertificatePublicKeyAction.NoWriteFile.message"), exportFile);

        JOptionPane.showMessageDialog(frame, message,
                res.getString("ExportTrustedCertificatePublicKeyAction.ExportPublicKeyOpenSsl.Title"),
                JOptionPane.WARNING_MESSAGE);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}

From source file:com.tiempometa.muestradatos.JReadTags.java

private void deleteReadButtonActionPerformed(ActionEvent e) {
    int response = JOptionPane.showConfirmDialog(this,
            "Se borrar el tag seleccionado.\nEsta operacin no se puede deshacer.\nContinuar?", "Borrar tags",
            JOptionPane.WARNING_MESSAGE);
    if (response == JOptionPane.YES_OPTION) {
        try {// w ww  . ja  v a2 s  . com
            List<Rfid> rfids = tagTableModel.getData();
            for (Rfid rfid : rfids) {
                rfidDao.delete(rfid);
            }
            tagTableModel.setData(new ArrayList<Rfid>());
            tagTableModel.fireTableDataChanged();
        } catch (SQLException e1) {
            JOptionPane.showMessageDialog(this, "No se pudieron borrar todos los tags. " + e1.getMessage(),
                    "Error borrando tags", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:com.stefanbrenner.droplet.ui.actions.SaveFileAction.java

protected void showFileChooser() {
    int returnVal = fileChooser.showSaveDialog(getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {

        // Get the selected file
        File file = fileChooser.getSelectedFile();

        // check if file extension fits
        if (StringUtils.containsIgnoreCase(file.getName(), ".") //$NON-NLS-1$
                && !(StringUtils.endsWithIgnoreCase(file.getName(),
                        "." + IDropletContext.DROPLET_FILE_EXTENSION))) {
            JOptionPane.showMessageDialog(getFrame(), Messages.getString("SaveFileAction.extensionNotAllowed"), //$NON-NLS-1$
                    Messages.getString("SaveFileAction.wrongExtension"), //$NON-NLS-1$
                    JOptionPane.ERROR_MESSAGE);
            showFileChooser();/*  w ww. j  av  a 2s.com*/
            return;
        } else { // automatically add droplet file extension
            if (!StringUtils.endsWithIgnoreCase(file.getName(), "." + IDropletContext.DROPLET_FILE_EXTENSION)) {
                String newPath = StringUtils.join(file.getPath(), "." + IDropletContext.DROPLET_FILE_EXTENSION);
                file = new File(newPath);
            }
        }

        // check if file already exists
        if (file.exists()) {
            int retVal = JOptionPane.showConfirmDialog(getFrame(),
                    Messages.getString("SaveFileAction.overwriteFile"), Messages.getString("SaveFileAction.1"), //$NON-NLS-1$ //$NON-NLS-2$
                    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

            if (retVal == JOptionPane.NO_OPTION) {
                showFileChooser();
                return;
            }
        }

        saveFile(file);

        // set file to context
        getDropletContext().setFile(file);

    }
}

From source file:org.apache.taverna.activities.xpath.ui.config.XPathActivityConfigurationPanelProvider.java

/**
 * Check that user values in the UI are valid.
 *///from   w w  w. j  av  a  2  s . c o  m
@Override
public boolean checkValues() {
    // the only validity condition is the correctness of the XPath
    // expression -- so checking that
    int xpathExpressionStatus = XPathActivityConfigurationBean
            .validateXPath(this.configPanel.getCurrentXPathExpression());

    // show an explicit warning message to explain the problem
    if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_EMPTY) {
        JOptionPane.showMessageDialog(this, "XPath expression should not be empty", "XPath Activity",
                JOptionPane.WARNING_MESSAGE);
    } else if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_INVALID) {
        JOptionPane.showMessageDialog(this,
                "<html><center>XPath expression is invalid - hover the mouse over the XPath status<br>"
                        + "icon to get more information</center></html>",
                "XPath Activity", JOptionPane.WARNING_MESSAGE);
    }

    return (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_VALID);
}

From source file:net.sf.keystore_explorer.gui.actions.ExamineFileAction.java

public void openFile(File file) {

    if (file == null) {
        return;/*from ww  w . j ava 2s. co  m*/
    }

    OpenAction openAction = new OpenAction(kseFrame);
    FileInputStream is = null;
    try {

        // detect file type and use the right action class for opening the file
        is = new FileInputStream(file);
        CryptoFileType fileType = CryptoFileUtil.detectFileType(is);

        switch (fileType) {
        case JCEKS_KS:
        case JKS_KS:
        case PKCS12_KS:
        case BKS_KS:
        case BKS_V1_KS:
        case UBER_KS:
            openAction.openKeyStore(file);
            break;
        case CERT:
            openCert(file);
            break;
        case CRL:
            openCrl(file);
            break;
        case PKCS10_CSR:
        case SPKAC_CSR:
            openCsr(file, fileType);
            break;
        case UNKNOWN:
        default:
            JOptionPane.showMessageDialog(frame,
                    MessageFormat.format(res.getString("ExamineFileAction.UnknownFileType.message"), file),
                    res.getString("ExamineFileAction.ExamineFile.Title"), JOptionPane.WARNING_MESSAGE);
            break;
        }

    } catch (Exception ex) {
        DError.displayError(frame, ex);
    } finally {
        IOUtils.closeQuietly(is);
    }
}

From source file:Listeners.MyActionListener.java

@Override
public void actionPerformed(ActionEvent e) {
    switch (button.getName()) {
    case "abrir":
        getIListasRequest();/*w w  w. ja v  a2 s  .co  m*/
        break;
    case "eliminar":
        int n = JOptionPane.showConfirmDialog(vista,
                "Eliminar " + lista.getItems().get(list.getSelectedIndex()).getDescripcion() + "?",
                "Eliminar", JOptionPane.YES_NO_OPTION);
        if (n == 0) {
            lista.getItems_deleted().add(lista.getItems().get(list.getSelectedIndex()));
            lista.getItems().remove(list.getSelectedIndex());

        }
        System.out.println("n" + n);
        list.setListData(lista.getItems().toArray());
        break;
    case "anadir":
        addAction();
        break;
    case "delete":
        break;
    case "editar":
        editAction();
        break;
    case "sync":
        System.out.println("pulsado sync");
        break;
    case "guardar":
        saveAction();
        break;
    case "nuevo":
        lista.setCod(0);
        vista.getNomLista().setText("Lista sin nombre");
        lista.getItems().clear();
        lista.getItems_deleted().clear();
        list.setListData(lista.getItems().toArray());
        break;
    case "aceptarAdd":
        if (!validateAddAction(add.getNombre()))
            JOptionPane.showMessageDialog(add, "Debes insertar el nombre del producto", "Ops!",
                    JOptionPane.WARNING_MESSAGE);
        else {
            System.out.println(add.getNombre().getText() + "  " + add.getCantidad().getSelectedItem());
            lista.addItem(new Item(add.getNombre().getText(),
                    Integer.parseInt((String) add.getCantidad().getSelectedItem()), 0));
            list.setListData(lista.getItems().toArray());
            add.dispose();
        }
        break;
    case "aceptarEdit":
        if (!validateEditAction(edit.getNombre()))
            JOptionPane.showMessageDialog(add, "Debes insertar el nombre del producto", "Ops!",
                    JOptionPane.WARNING_MESSAGE);
        else {
            int new_check;
            if (edit.getCheck().isSelected())
                new_check = 1;
            else
                new_check = 0;
            if (old_cant != Integer.parseInt((String) edit.getCantidad().getSelectedItem())
                    || old_check != new_check || old_name != edit.getNombre().getText()) {
                lista.getItems().get(index).setCambiado(true);
                lista.getItems().get(index).setCheck_item(new_check);
                lista.getItems().get(index)
                        .setCantidad(Integer.parseInt((String) edit.getCantidad().getSelectedItem()));
                lista.getItems().get(index).setDescripcion(edit.getNombre().getText());
                list.setListData(lista.getItems().toArray());
                lista.setModificada(true);
            }
            edit.dispose();
        }
        break;
    case "aceptarOpen":
        int cod = open.getListas().getSelectedIndex();
        getItemsListaRequest(openLists.get(cod).getCod(), openLists.get(cod).getDescripcion());
        break;
    }

}

From source file:io.github.jeremgamer.editor.panels.Actions.java

public Actions(final JFrame frame, final ActionPanel ap) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;//w w  w  .j  av  a  2 s . c  om
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ActionSave(name);
                    OtherPanel.updateLists();
                    ButtonPanel.updateLists();
                    ActionPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (actionList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/actions/"
                            + actionList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null,
                            "tes-vous sr de vouloir supprimer cette action?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        if (actionList.getSelectedValue().equals(ap.getFileName())) {
                            ap.setFileName("");
                        }
                        ap.hide();
                        file.delete();
                        data.remove(actionList.getSelectedIndex());
                        OtherPanel.updateLists();
                        ButtonPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    actionList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(actionList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}