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:iics.Connection.java

static void create_dir() {

    try {//from ww w .ja v  a  2 s . co  m
        File directory = new File(dir);
        if (directory.exists()) {
            create_file();

        } else {
            System.out.println("Directory not exists, creating now");

            success = directory.mkdir();
            if (success) {
                create_file();
            } else {
                System.out.printf("Failed to create new directory: %s%n", dir);
                JOptionPane.showMessageDialog(null,
                        "                 An error occured!! \n Contact your system admin for help.", null,
                        JOptionPane.WARNING_MESSAGE);
                close_loda();
            }
        }
        fw = new FileWriter(f.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(content);
        bw.close();
    } catch (IOException ex) {
        //   Logger.getLogger(Extract.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null,
                "                 An error occured!! \n Contact your system admin for help.", null,
                JOptionPane.WARNING_MESSAGE);
        close_loda();
    } finally {
        try {
            fw.close();
        } catch (IOException ex) {
            //   Logger.getLogger(Extract.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null,
                    "                 An error occured!! \n Contact your system admin for help.", null,
                    JOptionPane.WARNING_MESSAGE);
            close_loda();
        }
    }
}

From source file:UserInterface.DonorRole.DonorRecordsJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    int selectedRow = donorHormoneLevelsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }//from  ww w.j a v a 2s. c  o m
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }

}

From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java

/**
 * Check that user values in the UI are valid.
 *//*from www.  j  a v  a 2s  . co m*/
@Override
public boolean checkValues() {
    // HTTP method is a fixed selection combo-box - no validation required

    // URL signature must be present and be valid
    String candidateURLSignature = tfURLSignature.getText().trim();
    if (candidateURLSignature == null || candidateURLSignature.length() == 0) {
        JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "URL signature must not be empty",
                "REST Activity Configuration - Warning", JOptionPane.WARNING_MESSAGE);
        return (false);
    } else {
        try {
            // Test if any exceptions will be thrown - if not, proceed to
            // other validations
            URISignatureHandler.validate(candidateURLSignature);
        } catch (URISignatureParsingException e) {
            JOptionPane.showMessageDialog(MainWindow.getMainWindow(), e.getMessage(),
                    "REST Activity Configuration - Warning", JOptionPane.WARNING_MESSAGE);
            return (false);
        }

        // Test if the URL string contains "unsafe" characters, i.e. characters
        // that need URL-encoding.
        // From RFC 1738: "...Only alphanumerics [0-9a-zA-Z], the special
        // characters "$-_.+!*'()," (not including the quotes) and reserved
        // characters used for their reserved purposes may be
        // used unencoded within a URL."
        // Reserved characters are: ";/?:@&=" ..." (excluding quotes) and "%" used
        // for escaping.
        // We do not warn the user if they have not properly enclosed parameter
        // names in curly braces as this check is already being done elsewhere in the code.
        // We do not check the characters in parameter names either.
        try {
            // Test if any exceptions will be thrown - if not, proceed to
            // other validations
            URISignatureHandler.checkForUnsafeCharacters(candidateURLSignature);
        } catch (URISignatureParsingException e) {
            JOptionPane.showMessageDialog(MainWindow.getMainWindow(), e.getMessage(),
                    "REST Activity Configuration - Warning", JOptionPane.WARNING_MESSAGE);
            return (false);
        }

        // Other HTTP headers configured must not have empty names
        ArrayList<String> otherHTTPHeaderNames = httpHeadersTableModel.getHTTPHeaderNames();
        for (String headerName : otherHTTPHeaderNames) {
            if (headerName.equals("")) {
                JOptionPane.showMessageDialog(MainWindow.getMainWindow(),
                        "One of the HTTP header names is empty", "REST Activity Configuration - Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }
        }
    }

    // All valid, return true
    return true;
}

From source file:UserInterface.EmployeeViewArea.ViewIssuesStatisticsJPanel.java

public JPanel createPiePanel(int ring, int call, int off, String title) {
    JFreeChart pieChart = createPieChart(createPieDataset());
    try {/*  www  .ja v a2 s  .  co m*/
        String fileName = String.valueOf(count);
        fileName += imageName[rand.nextInt(imageName.length)];
        saveToFile(pieChart, workingDir + "\\src\\Images" + "\\" + fileName + "plot.jpg", ring, call, off);
        count++;
        JOptionPane.showMessageDialog(null, "Image saved successfully", "Warning", JOptionPane.WARNING_MESSAGE);

    } catch (Exception e) {
        e.printStackTrace();
    }
    return new ChartPanel(pieChart);
}

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

private void openCsr(File csrFile, CryptoFileType fileType) {
    if (csrFile == null) {
        return;/*ww w. j a  v  a 2  s  . c om*/
    }

    try {
        PKCS10CertificationRequest pkcs10Csr = null;
        Spkac spkacCsr = null;

        try {
            if (fileType == CryptoFileType.PKCS10_CSR) {
                pkcs10Csr = Pkcs10Util.loadCsr(new FileInputStream(csrFile));
            } else if (fileType == CryptoFileType.SPKAC_CSR) {
                spkacCsr = new Spkac(new FileInputStream(csrFile));
            }
        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(frame,
                    MessageFormat.format(res.getString("ExamineCsrAction.NotFile.message"), csrFile),
                    res.getString("ExamineFileAction.ExamineCsr.Title"), JOptionPane.WARNING_MESSAGE);
            return;
        } catch (Exception ex) {
            String problemStr = MessageFormat.format(res.getString("ExamineFileAction.NoOpenCsr.Problem"),
                    csrFile.getName());

            String[] causes = new String[] { res.getString("ExamineFileAction.NotCsr.Cause"),
                    res.getString("ExamineFileAction.CorruptedCsr.Cause") };

            Problem problem = new Problem(problemStr, causes, ex);

            DProblem dProblem = new DProblem(frame, res.getString("ExamineFileAction.ProblemOpeningCsr.Title"),
                    problem);
            dProblem.setLocationRelativeTo(frame);
            dProblem.setVisible(true);

            return;
        }

        if (pkcs10Csr != null) {
            DViewCsr dViewCsr = new DViewCsr(frame, MessageFormat.format(
                    res.getString("ExamineFileAction.CsrDetailsFile.Title"), csrFile.getName()), pkcs10Csr);
            dViewCsr.setLocationRelativeTo(frame);
            dViewCsr.setVisible(true);
        } else {
            DViewCsr dViewCsr = new DViewCsr(frame, MessageFormat.format(
                    res.getString("ExamineFileAction.CsrDetailsFile.Title"), csrFile.getName()), spkacCsr);
            dViewCsr.setLocationRelativeTo(frame);
            dViewCsr.setVisible(true);
        }
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}

From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java

/**
 * ?/*  w  w  w.ja  va 2 s  .  c om*/
 * @param msg_code int
 */
private void showMsg(int msg_code) {
    String message = "";
    boolean flag = false;
    switch (msg_code) {
    case 0:
        flag = true;
        message = "???";
        break;
    case 1:
        message = "?????";
        break;
    case 2:
        message = "??";
        break;
    case 3:
        message = "XML??";
        break;
    case 4:
        message = "????";
        break;
    case 5:
        message = "???";
        break;
    }
    JOptionPane.showMessageDialog(this, message, "", JOptionPane.WARNING_MESSAGE);
    if (flag) {
        int closable = JOptionPane.showConfirmDialog(null,
                "???\n??", "??", JOptionPane.YES_NO_OPTION,
                JOptionPane.INFORMATION_MESSAGE);
        if (JOptionPane.YES_OPTION == closable) {
            System.exit(0);
        }
        return;
    }
}

From source file:de.atomfrede.tools.evalutation.ui.AppWindow.java

/**
 * Display a simple dialog, so the user does not close the application by
 * accident/*from   w w  w  .j ava  2  s.c o  m*/
 * 
 * @return
 */
private int reallyExit() {
    Object[] options = { Messages.getString("AppWindow.11"), Messages.getString("AppWindow.12") }; //$NON-NLS-1$ //$NON-NLS-2$

    int result = JOptionPane.showOptionDialog(frame, Messages.getString("AppWindow.13"), //$NON-NLS-1$
            Messages.getString("AppWindow.14"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
            JOptionPane.WARNING_MESSAGE, Icons.IC_DIALOG_WARNING_LARGE, options, options[1]);

    return result;
}

From source file:com.enderville.enderinstaller.ui.Installer.java

private void advanceStep() {
    step++;//w  ww  .j  a va 2 s . co m
    switch (step) {
    case 1: {
        String msg = InstallScript.preInstallCheck();
        if (msg != null) {
            //TODO maybe a better way to check for collisions
            // so that non-conflicting installs doesn't raise this warning
            msg = msg + "\nThe EnderPack is meant to be installed on a fresh minecraft.jar and mods folder.\n"
                    + "Do you wish to continue, and attempt to install on top of the current minecraft?";
            int opt = JOptionPane.showConfirmDialog(this, msg, "Installation Warning",
                    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (opt == JOptionPane.NO_OPTION) {
                setVisible(false);
                dispose();
            }
        }
        File extraFolder = new File(InstallerConfig.getExtraModsFolder());
        //Check that the extras folder exists and that it has some mods in it. Otherwise, simply start installing
        if (extraFolder.exists()) {
            File[] children = extraFolder.listFiles();
            if (children != null) {
                for (File child : children) {
                    if (child.isDirectory()) {
                        buildOptionsPane();
                        return;
                    }
                }
            }
            //extras folder was empty, or no mod directories (only files)
            advanceStep();
        } else {
            //extras folder didn't exist.
            advanceStep();
        }
        return;
    }
    case 2:
        buildInstallingPane();
        return;
    default:
        LOGGER.error("Advanced too far");
    }
}

From source file:UserInterface.ReciepientRole.RecepientRecordJPanel.java

private void viewStatsJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewStatsJBtnActionPerformed
    int selectedRow = recHormonalRecordsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }// w  w  w  . jav a2  s .  c  o  m
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);

    }
}

From source file:com.dmrr.asistenciasx.Horarios.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    try {/*from   w w  w  .  ja va2 s .co m*/
        int x = jTableHorarios.getSelectedRow();
        if (x == -1) {
            JOptionPane.showMessageDialog(this, "Seleccione un profesor primero", "Datos incompletos",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }
        Integer idProfesor = Integer
                .parseInt((String) jTableHorarios.getValueAt(jTableHorarios.getSelectedRow(), 1));

        JPasswordField pf = new JPasswordField();
        String nip = "";
        int okCxl = JOptionPane.showConfirmDialog(null, pf, "Introduzca el NIP del jefe del departamento",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        if (okCxl == JOptionPane.OK_OPTION) {
            nip = new String(pf.getPassword());
        } else {
            return;
        }

        org.jsoup.Connection.Response respuesta = Jsoup
                .connect("http://siiauescolar.siiau.udg.mx/wus/gupprincipal.valida_inicio")
                .data("p_codigo_c", "2225255", "p_clave_c", nip).method(org.jsoup.Connection.Method.POST)
                .timeout(0).execute();

        Document login = respuesta.parse();
        String sessionId = respuesta.cookie(getFecha() + "SIIAUSESION");
        String sessionId2 = respuesta.cookie(getFecha() + "SIIAUUDG");

        Document listaHorarios = Jsoup.connect("http://siiauescolar.siiau.udg.mx/wse/sspsecc.consulta_oferta")
                .data("ciclop", "201510", "cup", "J", "deptop", "", "codprofp", "" + idProfesor, "ordenp", "0",
                        "mostrarp", "1000", "tipop", "T", "secp", "A", "regp", "T")
                .userAgent("Mozilla").cookie(getFecha() + "SIIAUSESION", sessionId)
                .cookie(getFecha() + "SIIAUUDG", sessionId2).timeout(0).post();

        Elements tabla = listaHorarios.select("body");
        tabla.select("style").remove();
        Elements font = tabla.select("font");
        font.removeAttr("size");

        System.out.println(tabla.html());

        JEditorPane jEditorPane = new JEditorPane();
        jEditorPane.setEditable(false);

        HTMLEditorKit kit = new HTMLEditorKit();
        jEditorPane.setEditorKit(kit);

        javax.swing.text.Document doc = kit.createDefaultDocument();
        jEditorPane.setDocument(doc);
        jEditorPane.setText(tabla.html());

        JOptionPane.showMessageDialog(null, jEditorPane);

    } catch (IOException ex) {
        Logger.getLogger(Horarios.class.getName()).log(Level.SEVERE, null, ex);
    }

}