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:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java

private void abreUrl() {
    String url;//ww  w . ja  va 2s  . c om
    url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://");
    PegarPaginaWEB ppw = new PegarPaginaWEB();
    if (url != null) {
        try {
            String codHtml = ppw.getContent(url);
            TxtBuffer.setContentOriginal(codHtml, "0");
            parentFrame.showPainelFerramentaScriptPArq(codHtml);
            EstadoSilvinha.setLinkAtual(url);
        } catch (HttpException e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        } catch (Exception e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:de.huxhorn.lilith.swing.MainFrame.java

public void importFile(File importFile) {
    if (logger.isInfoEnabled())
        logger.info("Import file: {}", importFile.getAbsolutePath());

    File parentFile = importFile.getParentFile();
    String inputName = importFile.getName();
    if (!importFile.isFile()) {
        String message = "'" + importFile.getAbsolutePath() + "' is not a file!";
        JOptionPane.showMessageDialog(this, message, "Can't import file...", JOptionPane.ERROR_MESSAGE);
        return;/*  w  ww.  jav a  2s  .  c  o m*/
    }
    if (!importFile.canRead()) {
        String message = "Can't read from '" + importFile.getAbsolutePath() + "'!";
        JOptionPane.showMessageDialog(this, message, "Can't import file...", JOptionPane.ERROR_MESSAGE);
        return;
    }

    File dataFile = new File(parentFile, inputName + FileConstants.FILE_EXTENSION);
    File indexFile = new File(parentFile, inputName + FileConstants.INDEX_FILE_EXTENSION);

    // check if file exists and warn in that case
    if (dataFile.isFile()) {
        // check if file is already open
        ViewContainer<?> viewContainer = resolveViewContainer(dataFile);
        if (viewContainer != null) {
            showView(viewContainer);
            String message = "File '" + dataFile.getAbsolutePath() + "' is already open.";
            JOptionPane.showMessageDialog(this, message, "File is already open...",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        String dialogTitle = "Reimport file?";
        String message = "Data file does already exist!\nReimport data file right now?";
        int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (JOptionPane.OK_OPTION != result) {
            return;
        }

        if (dataFile.delete()) {
            if (logger.isInfoEnabled())
                logger.info("Deleted file '{}'.", dataFile.getAbsolutePath());
        }
    }
    if (indexFile.isFile()) {
        if (indexFile.delete()) {
            if (logger.isInfoEnabled())
                logger.info("Deleted file '{}'.", indexFile.getAbsolutePath());
        }
    }

    Map<String, String> metaData = new HashMap<String, String>();
    metaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF);
    metaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_LOGGING);
    metaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP);

    FileBuffer<EventWrapper<LoggingEvent>> buffer = loggingFileBufferFactory.createBuffer(dataFile, indexFile,
            metaData);

    ImportType type = resolveType(importFile);
    if (type == ImportType.LOG4J) {
        String name = "Importing Log4J XML file";
        String description = "Importing Log4J XML file '" + importFile.getAbsolutePath() + "'...";
        Task<Long> task = longTaskManager.startTask(new Log4jImportCallable(importFile, buffer), name,
                description);
        if (logger.isInfoEnabled())
            logger.info("Task-Name: {}", task.getName());
        return;
    }
    if (type == ImportType.JUL) {
        String name = "Importing java.util.logging XML file";
        String description = "Importing java.util.logging XML file '" + importFile.getAbsolutePath() + "'...";
        Task<Long> task = longTaskManager.startTask(new JulImportCallable(importFile, buffer), name,
                description);
        if (logger.isInfoEnabled())
            logger.info("Task-Name: {}", task.getName());
        return;
    }

    // show warning "Unknown type"
    String message = "Couldn't detect type of file '" + importFile.getAbsolutePath()
            + "'.\nFile is unsupported.";
    JOptionPane.showMessageDialog(this, message, "Unknown file type...", JOptionPane.WARNING_MESSAGE);
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java

private void abreUrl() {
    String url;/*from w ww .  j  av a2  s  . c  om*/
    url = JOptionPane.showInputDialog(this, GERAL.DIGITE_ENDERECO, "http://");
    PegarPaginaWEB ppw = new PegarPaginaWEB();
    if (url != null) {
        try {
            String codHtml = ppw.getContent(url);
            TxtBuffer.setContentOriginal(codHtml, "0");
            parentFrame.showPainelFerramentaDescricaoObjetosPArq(codHtml);
            EstadoSilvinha.setLinkAtual(url);
        } catch (HttpException e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        } catch (Exception e1) {
            JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL,
                    TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:edu.ku.brc.specify.tasks.InteractionsTask.java

/**
 * Creates an Excel SpreadSheet or CVS file and attaches it to an email and send it to an agent.
 *///from   w w  w . j  av a 2s .  c  o  m
public void createAndSendEMail() {
    FormViewObj formViewObj = getCurrentFormViewObj();
    if (formViewObj != null && formViewObj.getDataObj() instanceof InfoRequest) {
        InfoRequest infoRequest = (InfoRequest) formViewObj.getDataObj();
        Agent toAgent = infoRequest.getAgent();

        boolean sendEMail = true; // default to true
        Component comp = formViewObj.getControlByName("sendEMail");
        if (comp instanceof JCheckBox) {
            sendEMail = ((JCheckBox) comp).isSelected();
        }

        MultiView mv = formViewObj.getSubView("InfoRequestColObj");
        if (mv != null && sendEMail) {
            final Viewable viewable = mv.getCurrentView();
            if (viewable instanceof TableViewObj) {
                final Hashtable<String, String> emailPrefs = new Hashtable<String, String>();
                if (!EMailHelper.isEMailPrefsOK(emailPrefs)) {
                    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                            getResourceString("NO_EMAIL_PREF_INFO"),
                            getResourceString("NO_EMAIL_PREF_INFO_TITLE"), JOptionPane.WARNING_MESSAGE);
                    return;
                }

                final File tempExcelFileName = TableModel2Excel.getTempExcelName();

                emailPrefs.put("to", toAgent.getEmail() != null ? toAgent.getEmail() : "");
                emailPrefs.put("from", emailPrefs.get("email"));
                emailPrefs.put("subject", String.format(getResourceString("INFO_REQUEST_SUBJECT"),
                        new Object[] { infoRequest.getIdentityTitle() }));
                emailPrefs.put("bodytext", "");
                emailPrefs.put("attachedFileName", tempExcelFileName.getName());

                final Frame topFrame = (Frame) UIRegistry.getTopWindow();
                final ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog(topFrame, "SystemSetup",
                        "SendMail", null, getResourceString("SEND_MAIL_TITLE"), getResourceString("SEND_BTN"),
                        null, // className,
                        null, // idFieldName,
                        true, // isEdit,
                        0);
                dlg.setData(emailPrefs);
                dlg.setModal(true);
                dlg.setVisible(true);

                if (dlg.getBtnPressed() == ViewBasedDisplayIFace.OK_BTN) {
                    dlg.getMultiView().getDataFromUI();

                    //System.out.println("["+emailPrefs.get("bodytext")+"]");

                    TableViewObj tblViewObj = (TableViewObj) viewable;
                    File excelFile = TableModel2Excel.convertToExcel(tempExcelFileName,
                            getResourceString("CollectionObject"), tblViewObj.getTable().getModel());
                    StringBuilder sb = TableModel2Excel.convertToHTML(getResourceString("CollectionObject"),
                            tblViewObj.getTable().getModel());

                    //EMailHelper.setDebugging(true);
                    String text = emailPrefs.get("bodytext").replace("\n", "<br>") + "<BR><BR>" + sb.toString();
                    UIRegistry.displayLocalizedStatusBarText("SENDING_EMAIL");

                    String password = Encryption.decrypt(emailPrefs.get("password"));
                    if (StringUtils.isEmpty(password)) {
                        password = EMailHelper.askForPassword(topFrame);
                    }

                    if (StringUtils.isNotEmpty(password)) {
                        final EMailHelper.ErrorType status = EMailHelper.sendMsg(emailPrefs.get("smtp"),
                                emailPrefs.get("username"), password, emailPrefs.get("email"),
                                emailPrefs.get("to"), emailPrefs.get("subject"), text, EMailHelper.HTML_TEXT,
                                emailPrefs.get("port"), emailPrefs.get("security"), excelFile);
                        if (status != EMailHelper.ErrorType.Cancel) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    UIRegistry.displayLocalizedStatusBarText(
                                            status == EMailHelper.ErrorType.Error ? "EMAIL_SENT_ERROR"
                                                    : "EMAIL_SENT_OK");
                                }
                            });
                        }
                    }
                }
            }
        }
    } else {
        log.error("Why doesn't the current SubPane have a main FormViewObj?");
    }
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    l.info("Edit game action activated");
    MainFrame.lockInterface();//from www  . ja  v  a2 s  .  co  m
    MainFrame.updateTask("Editing game...", true);
    l.info("Starting game edit action");
    DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel();
    final int row = jTable1.getSelectedRow();
    if (row >= 0 && mdl.getValueAt(row, 0) != null) {
        AddGameDialog addGameDialog = new AddGameDialog(this, true);
        addGameDialog.setLocationRelativeTo(null);
        //addGameDialog.setVisible(true);
        final Game temp = GamelistStorage.getGame((String) mdl.getValueAt(row, 0));
        final Game g = addGameDialog.popupEditDialog(temp);
        if (g != null) {
            l.trace("Edit done, checking for changes");
            //l.trace("Calculating folder size: " + g.gameAbsoluteFolderPath);
            MainFrame.updateTask("Checking for changes...", true);
            MainFrame.updateGameInterfaceFromStorage();
            boolean changed = true;
            if (temp.gameAbsoluteExecPath.equals(g.gameAbsoluteExecPath)
                    && temp.gameAbsoluteFolderPath.equals(g.gameAbsoluteFolderPath)) {
                l.trace("Location same - assuming no changes made");
                g.gameName = temp.gameName;
                g.gameBatCommands = temp.gameBatCommands;
                g.gamePName = temp.gamePName;
                g.gamePUser = temp.gamePUser;
                g.gamePWName = temp.gamePWName;
                g.gameRuntimeFlags = temp.gameRuntimeFlags;
                changed = false;
            } else {
                l.trace("Locations changed - rescanning the game");
                g.gameStatus = 0;
                MainFrame.updateProgressBar(0, 0, 0, "Calculating game size", true, true);
                final ObjectPlaceholder obj = new ObjectPlaceholder();
                SwingWorker worker = new SwingWorker<Long, Void>() {

                    @Override
                    public Long doInBackground() throws IOException {
                        MainFrame.lockInterface();
                        l.trace("Checking size");
                        MainFrame.updateProgressBar(0, 0, 0, "Analyzing game size", true, true);
                        obj.payload = FileUtils.sizeOfDirectory(new File(g.gameAbsoluteFolderPath));
                        l.trace("Checking files");
                        MainFrame.updateProgressBar(0, 0, 0, "Analyzing game files", true, true);
                        g.gameFileNumber = FileUtils.listFiles(new File(g.gameAbsoluteFolderPath), null, true)
                                .size();
                        l.trace("Checking CRC32");
                        MainFrame.updateProgressBar(0, 0, 0, "Analyzing game signature", true, true);
                        g.gameExecCRC32 = FileUtils.checksumCRC32(new File(g.gameAbsoluteExecPath));
                        return ((Long) obj.payload);
                    }

                    @Override
                    public void done() {
                        l.trace("Finishing game check");
                        MainFrame.updateProgressBar(0, 0, 0, "Finishing game edit", false, false);
                        g.gameSize = ((Long) obj.payload);
                        /*
                        double mbsize = Math.ceil(g.gameSize / (1024 * 1024));
                        jTable1.getModel().setValueAt(mbsize, row, 2);
                         *
                         */
                        g.copyTo(temp);
                        Shared.lastCreatedGame = null;
                        l.trace("Done editing game");
                        MainFrame.updateGameInterfaceFromStorage();
                        MainFrame.unlockInterface();
                        MainFrame.setReportingIdle();
                    }
                };
                worker.execute();
            }
            //we are trusting the size task to finish here ELSE TROUBLE
            /*
            GamelistStorage.removeGame(temp.gameName);
            GamelistStorage.addGame(g);
             * 
             */
            if (!changed) {
                MainFrame.unlockInterface();
                MainFrame.setReportingIdle();
            }
            MainFrame.updateGameInterfaceFromStorage();
        } else {
            MainFrame.unlockInterface();
            MainFrame.setReportingIdle();
            MainFrame.updateGameInterfaceFromStorage();
        }
    } else {
        l.trace("Game edit - bad selection or empty table");
        JOptionPane.showMessageDialog(this, "Invalid selection - can't edit", "Edit error",
                JOptionPane.WARNING_MESSAGE);
        MainFrame.unlockInterface();
        MainFrame.setReportingIdle();
        MainFrame.updateGameInterfaceFromStorage();
    }
}

From source file:client.ui.FilePane.java

private void refreshNoteAndText() {
    CloudFile selectedFile = getSelectedFile();
    if (selectedFile == null) { //
        clearNoteAndText(); //note
    } else {/*ww w.j  av a2  s.c  o m*/
        try {
            NoteListResult noteListResult = m_Business.getNoteList(selectedFile);
            NoteListStatus noteStatus = noteListResult.getResult();
            switch (noteStatus) {
            case OK:
                ArrayList<Note> noteList = noteListResult.getNoteList();
                Collections.sort(noteList);
                noteTable.getRowSorter().setSortKeys(null);
                noteTableModel.setNoteList(noteList);
                noteTable.setModel(noteTableModel);
                noteTable.clearSelection();
                noteTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                if (selectedFile.getFilename().endsWith(".txt")) {
                    DownloadFileResult downloadFileResult = m_Business.downloadFile(selectedFile);
                    DownloadFileStatus fileStatus = downloadFileResult.getResult();
                    switch (fileStatus) {
                    case OK:
                        String content = IOUtils.toString(downloadFileResult.getContent(), "gbk");
                        fileContentArea.setText(content);
                        noteTable.repaint();
                        fileContentArea.repaint();
                        break;
                    case unAuthorized:
                        JOptionPane.showMessageDialog(m_MainFrame, "?",
                                "", JOptionPane.WARNING_MESSAGE);
                        m_MainFrame.setVisible(false);
                        LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
                        break;
                    case wrong:
                        JOptionPane.showMessageDialog(m_MainFrame, "?", "",
                                JOptionPane.WARNING_MESSAGE);
                        getDirectory(currentID);
                        break;
                    default:
                        JOptionPane.showMessageDialog(m_MainFrame, "", "",
                                JOptionPane.ERROR_MESSAGE);
                        break;
                    }
                } else {
                    fileContentArea.setText("");
                    noteTable.repaint();
                    fileContentArea.repaint();
                }
                break;
            case unAuthorized:
                JOptionPane.showMessageDialog(m_MainFrame, "?", "",
                        JOptionPane.WARNING_MESSAGE);
                m_MainFrame.setVisible(false);
                LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
                break;
            case wrong:
                JOptionPane.showMessageDialog(m_MainFrame, "?", "",
                        JOptionPane.WARNING_MESSAGE);
                getDirectory(currentID);
                break;
            default:
                JOptionPane.showMessageDialog(m_MainFrame, "", "",
                        JOptionPane.ERROR_MESSAGE);
                break;
            }

        } catch (IOException e) {
            JOptionPane.showMessageDialog(m_MainFrame, "", "",
                    JOptionPane.ERROR_MESSAGE);
            clearNoteAndText();
        }
    }
}

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void jBexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBexcluirActionPerformed
        try {//from w  w w .j av  a  2  s  .c o  m
            // TODO add your handling code here:
            if (!jTidpessoa.getText().equals("")) {
                if (JOptionPane.showConfirmDialog(null, "Deseja Excluir o Registro", "Ateno",
                        JOptionPane.YES_NO_OPTION) == 0) {
                    new PessoaDao().deletePessoa(Integer.valueOf(jTidpessoa.getText()));
                    ativaNovoAlterarExcluir();
                    limpaView();
                    desativaView();
                    buscaPessoa();
                    JOptionPane.showMessageDialog(this, "Registro Excluido", "Excluir",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(this, "Selecione um Registro", "Excluir", JOptionPane.ERROR_MESSAGE);
            }
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Excluir" + ex, "Excluir", JOptionPane.WARNING_MESSAGE);
        }

    }

From source file:fur.shadowdrake.minecraft.InstallPanel.java

private void forceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forceActionPerformed
    if (force.isSelected()) {
        if (JOptionPane.showConfirmDialog(this,
                "Forcing a reinstall will clean up the directory resulting in a loss of all settings!",
                "Reinstall", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE) == JOptionPane.CANCEL_OPTION) {
            force.setSelected(false);/*from ww w. j ava2s  . co  m*/
            return;
        }
    }

    boolean isInstalled = false;
    for (Pack p : packList) {
        if (p.name.equals(modpackChooser.getSelectedItem())) {
            isInstalled = true;
        }
    }
    dirBox.setEnabled(!isInstalled || force.isSelected());
    browse.setEnabled(!isInstalled || force.isSelected());
}

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void jTtempresaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtempresaKeyPressed
        // TODO add your handling code here:

        int coluna = jTtempresa.getSelectedColumn();
        if ((evt.getKeyCode() == KeyEvent.VK_F) && (coluna >= 0)) {
            if (evt.isControlDown()) {
                String text = JOptionPane.showInputDialog(this, "Pesquisa: " + jTtempresa.getColumnName(coluna),
                        "PESQUISA", JOptionPane.WARNING_MESSAGE);
                if (text != null) {
                    //DefaultTableModel tabela = (DefaultTableModel) jTtmodulo.getModel();
                    //final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabela);
                    // jTtmodulo.setRowSorter(sorter);
                    text = text.toUpperCase();
                    if (jTtempresa.getColumnName(coluna).equals("RAZAO")) {
                        buscaPessoa("RAZAO", text);
                    }/*from ww  w  .j  ava 2s  . co m*/
                    if (jTtempresa.getColumnName(coluna).equals("FANTASIA")) {
                        buscaPessoa("FANTASIA", text);
                    }
                    if (jTtempresa.getColumnName(coluna).equals("CNPJ")) {
                        buscaPessoa("CNPJ", text);
                    }
                    if (jTtempresa.getColumnName(coluna).equals("ENDERECO")) {
                        buscaPessoa("ENDERECO", text);
                    }
                }

            }
        }
    }

From source file:Form.Principal.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    try {//from   w w  w.  jav a 2  s .  c o m
        String Comando = null;
        if (jTextField3.getText().equalsIgnoreCase("") || jTextField5.getText().equalsIgnoreCase("")
                || jTextField6.getText().equalsIgnoreCase("") || jTextField7.getText().equalsIgnoreCase("")
                || jTextField8.getText().equalsIgnoreCase("") || jTextField9.getText().equalsIgnoreCase("")
                || jTextField10.getText().equalsIgnoreCase("") || jTextField11.getText().equalsIgnoreCase("")) {
            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Datos incompletos", "Aviso", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);
        } else {
            Comando = "INSERT INTO cliente VALUES (default,'" + jTextField5.getText() + "','"
                    + jTextField6.getText() + "','" + jTextField10.getText() + "','" + jTextField9.getText()
                    + "','" + jTextField7.getText() + "','" + jTextField8.getText() + "','"
                    + jTextField3.getText() + "','" + jTextField11.getText() + "'); ";
            Funcion.Update(st, Comando);
            Autocompletar.removeAllItems();
            Autocompletar = new TextAutoCompleter(jTextField2);
            Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
            try {
                while (Comandos.next()) {
                    Autocompletar.addItem(Comandos.getString("RFC"));
                }
            } catch (SQLException ex) {
                //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            }
            //*******Limpiar
            jTextField5.setText("");
            jTextField6.setText("");
            jTextField10.setText("");
            jTextField8.setText("");
            jTextField9.setText("");
            jTextField7.setText("");
            jTextField3.setText("");
            jTextField11.setText("");
            jPanel7.setVisible(false);
            jButton2.setVisible(false);
            //jPanel6.setVisible(false);
            //jButton1.setVisible(false);
            jButton1.setEnabled(true);

            Object[] options = { "Aceptar" };
            JOptionPane.showOptionDialog(null, "Exito!", "Nuevo cliente", JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]);

            /*jButton8.setVisible(true);
            jButton9.setVisible(true);
            jButton10.setVisible(true);
            jButton3.setVisible(true);
            jButton11.setVisible(true); 
            FechaSistema();
            factura();
            CrearPanelPDF();*/
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error en los datos" + e.getMessage());
    }

}