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:gui_pack.MainGui.java

private void runTestsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runTestsButtonActionPerformed
    int rangeMin, rangeMax, spacing;
    int passing = 0;

    {//  Beginning of input validation
        String errorTitle, errorMessage;

        //make sure at least one sort algorithm is selected
        if (!(insertionCheckBox.isSelected() || mergeCheckBox.isSelected() || quickCheckBox.isSelected()
                || selectionCheckBox.isSelected())) {
            errorTitle = "Selection Error";
            errorMessage = "At least one sort algorithm (Insertion Sort, "
                    + "Merge Sort, Quick Sort, or Selection Sort) must be selected.";
            JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
            return;
        }/* w w w .ja  va2 s.com*/

        //make sure at least one order is selected
        if (!(ascendingCheckBox.isSelected() || descendingCheckBox.isSelected()
                || randomCheckBox.isSelected())) {
            errorTitle = "Selection Error";
            errorMessage = "At least one order (Ascending Order, Descending Order, or Random Order) "
                    + "must be selected.";
            JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
            return;
        }

        //make sure all the proper fields contain data
        try {
            rangeMin = Integer.parseInt(rangeMinField.getText());
            rangeMax = Integer.parseInt(rangeMaxField.getText());
            spacing = Integer.parseInt(spacingField.getText());
            //for the multithreaded version of this program "iterations" cannot be a variable
            //this was left in to catch if the iteration field is left blank or has no value
            if (iterationField.isEnabled()) {
                Integer.parseInt(iterationField.getText());
            }
        } catch (NumberFormatException arbitraryName) {
            errorTitle = "Input Error";
            if (iterationField.isEnabled()) {
                errorMessage = "The size, intervals, and iterations fields must contain "
                        + "integer values and only integer values.";
            } else {
                errorMessage = "The size and intervals fields must contain "
                        + "integer values and only integer values.";
            }
            JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
            return;
        }

        //make sure field data is appropriate
        if (rangeMin > rangeMax) {
            errorTitle = "Range Error";
            errorMessage = "Minimum Size must be less than or equal to Maximum Size.";
            JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
            return;
        }

        if (spacing < 1 || rangeMin < 1 || rangeMax < 1
                || (iterationField.isEnabled() && Integer.parseInt(iterationField.getText()) < 1)) {
            errorTitle = "Value Error";
            if (iterationField.isEnabled()) {
                errorMessage = "Intervals, sizes, and iterations must be in the positive domain. "
                        + "Spacing, Range(min), Range(max), and Iterations must be greater than or"
                        + " equal to one.";
            } else {
                errorMessage = "Intervals and sizes must be in the positive domain. "
                        + "Spacing, Range(min) and Range(max) be greater than or" + " equal to one.";
            }
            JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE);
            return;
        }

        if (!iterationField.isEnabled()) {
            passing = 0;
        }

    } // End of input validation

    //here's where we set up a loading bar in case the tests take a while
    JProgressBar loadBar = new JProgressBar();
    JFrame loadFrame = new JFrame();
    JLabel displayLabel1 = new JLabel();
    loadBar.setIndeterminate(true);
    loadBar.setVisible(true);
    displayLabel1.setText("Running large tests, or many tests, using inefficient algorithms \n"
            + "may take a while. Please be patient.");
    loadFrame.setLayout(new FlowLayout());
    loadFrame.add(loadBar);
    loadFrame.add(displayLabel1);
    loadFrame.setSize(600, 100);
    loadFrame.setTitle("Loading");
    loadFrame.setVisible(true);

    //now we will leave this open until the tests are completed
    //now we can conduct the actual tests
    SwingWorker worker = new SwingWorker<XYSeriesCollection, Void>() {
        XYSeriesCollection results = new XYSeriesCollection();

        @Override
        protected XYSeriesCollection doInBackground() {
            XYSeries insertSeries = new XYSeries("Insertion Sort");
            XYSeries mergeSeries = new XYSeries("Merge Sort");
            XYSeries quickSeries = new XYSeries("Quick Sort");
            XYSeries selectSeries = new XYSeries("Selection Sort");

            final boolean ascending = ascendingCheckBox.isSelected();
            final boolean descending = descendingCheckBox.isSelected();
            final boolean insertion = insertionCheckBox.isSelected();
            final boolean merge = mergeCheckBox.isSelected();
            final boolean quick = quickCheckBox.isSelected();
            final boolean selection = selectionCheckBox.isSelected();

            final int iterations = Integer.parseInt(iterationField.getText());

            ListGenerator generator = new ListGenerator();
            int[] list;
            for (int count = rangeMin; count <= rangeMax; count = count + spacing) {

                if (ascending) {

                    list = generator.ascending(count);
                    if (insertion) {
                        insertSeries.add(count, insertionSort.sort(list));
                    }
                    if (merge) {
                        mergeSeries.add(count, mergeSort.sort(list));
                    }
                    if (quick) {
                        quickSeries.add(count, quickSort.sort(list));
                    }
                    if (selection) {
                        selectSeries.add(count, selectionSort.sort(list));
                    }
                }
                if (descending) {

                    list = generator.descending(count);
                    if (insertion) {
                        insertSeries.add(count, insertionSort.sort(list));
                    }
                    if (merge) {
                        mergeSeries.add(count, mergeSort.sort(list));
                    }
                    if (quick) {
                        quickSeries.add(count, quickSort.sort(list));
                    }
                    if (selection) {
                        selectSeries.add(count, selectionSort.sort(list));
                    }
                }

                for (int iteration = 0; iteration < iterations; iteration++) {
                    list = generator.random(count);

                    if (insertion) {
                        insertSeries.add(count, insertionSort.sort(list));
                    }
                    if (merge) {
                        mergeSeries.add(count, mergeSort.sort(list));
                    }
                    if (quick) {
                        quickSeries.add(count, quickSort.sort(list));
                    }
                    if (selection) {
                        selectSeries.add(count, selectionSort.sort(list));
                    }
                }

            }

            //now we aggregate the results
            if (insertion) {
                results.addSeries(insertSeries);
            }
            if (merge) {
                results.addSeries(mergeSeries);
            }
            if (quick) {
                results.addSeries(quickSeries);
            }
            if (selection) {
                results.addSeries(selectSeries);
            }
            return results;
        }

        @Override
        protected void done() {
            //finally, we display the results
            JFreeChart chart = ChartFactory.createScatterPlot("SortExplorer", // chart title
                    "List Size", // x axis label
                    "Number of Comparisons", // y axis label
                    results, // data  
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );
            ChartFrame frame = new ChartFrame("First", chart);
            frame.pack();
            frame.setVisible(true);
            loadFrame.setVisible(false);
        }
    };

    //having set up the multithreading 'worker' we can finally conduct the 
    //test
    worker.execute();

}

From source file:userinterface.Citizen.CitizenWorkAreaJPanel.java

private void dispalyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dispalyButtonActionPerformed
    int selectedRow = vitalSigntable.getSelectedRow();
    if (selectedRow >= 0) {
        VitalSign vs = (VitalSign) vitalSigntable.getValueAt(selectedRow, 0);
        resRateField.setText(String.valueOf(vs.getRespiratoryRate()));
        heartRateField.setText(String.valueOf(vs.getHeartRate()));
        bpField.setText(String.valueOf(vs.getSystolicBloodPressure()));
        weightField.setText(String.valueOf(vs.getWeight()));
    } else {//from  ww  w.ja va  2s  .  co m
        JOptionPane.showMessageDialog(null, "Please select a row from the table first", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:client.ui.FilePane.java

private void renameFileButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_renameFileButtonActionPerformed
    CloudFile selectedFile = getSelectedFile();
    if (selectedFile == null) {
        JOptionPane.showMessageDialog(this, "", "???", JOptionPane.WARNING_MESSAGE);
        return;//  ww  w. ja  va2  s .  c o m
    }

    String newFilename = JOptionPane.showInputDialog(m_MainFrame, "??");
    if (newFilename == null) {
        //fileInfoTable.clearSelection();
        return;
    }

    if (newFilename.equals("")) {
        JOptionPane.showMessageDialog(this, "??", "???",
                JOptionPane.WARNING_MESSAGE);
        return;
    }

    try {
        RenameFileResult result = m_Business.renameFile(selectedFile, newFilename);
        switch (result) {
        case OK:
            JOptionPane.showMessageDialog(this, "????", "???",
                    JOptionPane.INFORMATION_MESSAGE);
            getDirectory(currentID);
            break;
        case unAuthorized:
            JOptionPane.showMessageDialog(this, "?", "???",
                    JOptionPane.WARNING_MESSAGE);
            m_MainFrame.setVisible(false);
            LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
            break;
        case wrong:
            JOptionPane.showMessageDialog(this, "??", "???",
                    JOptionPane.WARNING_MESSAGE);
            getDirectory(currentID);
            break;
        case repeatedName:
            JOptionPane.showMessageDialog(this, "???", "???",
                    JOptionPane.WARNING_MESSAGE);
            break;
        default:
            JOptionPane.showMessageDialog(m_MainFrame, "", "???", JOptionPane.ERROR_MESSAGE);
            break;
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(m_MainFrame, "", "???", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java

private void confirmBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmBtnActionPerformed
    int selectedRow = vitalSignAlertsTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Please select a row", "WARNING", JOptionPane.WARNING_MESSAGE);
        return;/*from   w  ww.ja  v a 2s.c  o m*/
    } else {

        HosptoHouseWorkRequest request = (HosptoHouseWorkRequest) vitalSignAlertsTable.getValueAt(selectedRow,
                0);
        if (request.getStatus().equals("Requested Visit")) {
            request.setStatus("Confirmed");
            populateAlertFamilyTable();
        } else if (request.getStatus().equals("Visited")) {
            JOptionPane.showMessageDialog(null, "Patient has already visited.Kindly confirm a new request",
                    "WARNING", JOptionPane.WARNING_MESSAGE);
        } else if (request.getStatus().equals("Dint Show Up")) {
            JOptionPane.showMessageDialog(null, "Patient dint show up.Kindly confirm a new request", "WARNING",
                    JOptionPane.WARNING_MESSAGE);
        } else if (request.getStatus().equals("Cancelled")) {
            JOptionPane.showMessageDialog(null, "Visit is cancelled.Kindly confirm a new request", "WARNING",
                    JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "Appointment not requested", "WARNING",
                    JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:brainflow.app.toplevel.BrainFlow.java

private IImageSource specialHandling(IImageSource dataSource) {

    if (dataSource.getFileFormat().equals("Analyze7.5")) {
        JPanel panel = new JPanel();
        JLabel messageLabel = new JLabel("Please select correct image orientation from menu: ");
        java.util.List<Anatomy3D> choices = Anatomy3D.getInstanceList();
        JComboBox choiceBox = new JComboBox(choices.toArray());

        //todo hackery alert
        Anatomy anatomy = dataSource.getImageInfo().getAnatomy();
        choiceBox.setSelectedItem(anatomy);

        FormLayout layout = new FormLayout("4dlu, l:p, p:g, 4dlu", "6dlu, p, 10dlu, p, 6dlu");
        CellConstraints cc = new CellConstraints();
        panel.setLayout(layout);/*from w  w  w.ja  va2 s.  co  m*/
        panel.add(messageLabel, cc.xyw(2, 2, 2));
        panel.add(choiceBox, cc.xyw(2, 4, 2));

        JOptionPane.showMessageDialog(brainFrame, panel, "Analyze 7.5 image format ...",
                JOptionPane.WARNING_MESSAGE);
        Anatomy selectedAnatomy = (Anatomy) choiceBox.getSelectedItem();
        if (selectedAnatomy != anatomy) {
            //todo hackery alert
            dataSource.getImageInfo().setAnatomy((Anatomy3D) selectedAnatomy);
            dataSource.releaseData();
        }
    }

    return dataSource;

}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void chooseServer() {
    final TwoObjectsX<String, String> serverAndClientId = new TwoObjectsX<String, String>(
            iliasProperties.getIliasServerURL(), iliasProperties.getIliasClient());
    final boolean noConfigDoneYet = serverAndClientId.getObjectA() == null
            || serverAndClientId.getObjectA().trim().isEmpty();

    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    final JLabel labelServer = new JLabel("Server: " + serverAndClientId.getObjectA());
    final JLabel labelClientId = new JLabel("Client Id: " + serverAndClientId.getObjectB());

    JComboBox<LoginType> comboboxLoginType = null;
    JComboBox<DownloadMethod> comboboxDownloadMethod = null;

    final Runnable findOutClientId = new Runnable() {

        @Override// www .  j  ava  2 s .  c o m
        public void run() {
            try {
                String s = IliasUtil.findClientByLoginPageOrWebserviceURL(serverAndClientId.getObjectA());
                serverAndClientId.setObjectB(s);
                labelClientId.setText("Client Id: " + s);
            } catch (Exception e1) {
                showError("Client Id konnte nicht ermittelt werden", e1);
            }
        }
    };

    final Runnable promptInputServer = new Runnable() {

        @Override
        public void run() {

            String s = JOptionPane.showInputDialog(panel,
                    "Geben Sie die Ilias Loginseitenadresse oder Webserviceadresse ein",
                    serverAndClientId.getObjectA());
            if (s != null) {
                try {
                    s = IliasUtil.findSOAPWebserviceByLoginPage(s.trim());

                    if (!s.toLowerCase().startsWith("https://")) {
                        JOptionPane.showMessageDialog(mainFrame,
                                "Achtung! Die von Ihnen angegebene Adresse beginnt nicht mit 'https://'.\nDie Verbindung ist daher nicht ausreichend gesichert. Ein Angreifer knnte Ihre Ilias Daten und Ihr Passwort abgreifen",
                                "Achtung, nicht geschtzt", JOptionPane.WARNING_MESSAGE);
                    }

                    serverAndClientId.setObjectA(s);
                    labelServer.setText("Server: " + serverAndClientId.getObjectA());

                    if (noConfigDoneYet) {
                        findOutClientId.run();
                    }
                } catch (IliasException e1) {
                    showError(
                            "Bitte geben Sie die Adresse der Ilias Loginseite oder die des Webservice an. Die Adresse der Loginseite muss 'login.php' enthalten",
                            e1);
                }
            }
        }
    };

    {
        JPanel panel2 = new JPanel(new BorderLayout());

        panel2.add(labelServer, BorderLayout.NORTH);
        panel2.add(labelClientId, BorderLayout.SOUTH);

        panel.add(panel2, BorderLayout.NORTH);
    }
    {
        JPanel panel2 = new JPanel(new BorderLayout());

        JPanel panel3 = new JPanel(new GridLayout());
        {
            JButton b = new JButton("Server ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    promptInputServer.run();
                }
            });
            panel3.add(b);

            b = new JButton("Client Id ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String s = JOptionPane.showInputDialog(panel, "Client Id eingeben",
                            serverAndClientId.getObjectB());
                    if (s != null) {
                        serverAndClientId.setObjectB(s);
                        labelClientId.setText("Client Id: " + serverAndClientId.getObjectB());
                    }

                }
            });
            panel3.add(b);

            b = new JButton("Client Id automatisch ermitteln");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    findOutClientId.run();
                }
            });
            panel3.add(b);
        }
        panel2.add(panel3, BorderLayout.NORTH);

        panel3 = new JPanel(new GridLayout(0, 2, 5, 2));
        {
            panel3.add(new JLabel("Loginmethode: "));
            comboboxLoginType = new JComboBox<LoginType>();
            FunctionsX.setComboBoxLayoutString(comboboxLoginType, new ObjectDoInterface<LoginType, String>() {

                @Override
                public String doSomething(LoginType loginType) {
                    switch (loginType) {
                    case DEFAULT:
                        return "Standard";
                    case LDAP:
                        return "LDAP";
                    case CAS:
                        return "CAS";
                    default:
                        return "<Fehler>";
                    }
                }

            });
            val model = ((DefaultComboBoxModel<LoginType>) comboboxLoginType.getModel());
            for (LoginType loginType : LoginType.values()) {
                model.addElement(loginType);
            }
            model.setSelectedItem(iliasProperties.getLoginType());
            panel3.add(comboboxLoginType);

            JLabel label = new JLabel("Dateien herunterladen ber:");
            label.setToolTipText("Die restliche Kommunikation luft immer ber den SOAP Webservice");
            panel3.add(label);
            comboboxDownloadMethod = new JComboBox<DownloadMethod>();
            FunctionsX.setComboBoxLayoutString(comboboxDownloadMethod,
                    new ObjectDoInterface<DownloadMethod, String>() {

                        @Override
                        public String doSomething(DownloadMethod downloadMethod) {
                            switch (downloadMethod) {
                            case WEBSERVICE:
                                return "SOAP Webservice (Standard)";
                            case WEBDAV:
                                return "WEBDAV";
                            default:
                                return "<Fehler>";
                            }
                        }

                    });
            val model2 = ((DefaultComboBoxModel<DownloadMethod>) comboboxDownloadMethod.getModel());
            for (DownloadMethod downloadMethod : DownloadMethod.values()) {
                model2.addElement(downloadMethod);
            }
            model2.setSelectedItem(iliasProperties.getDownloadMethod());
            panel3.add(comboboxDownloadMethod);
        }
        panel2.add(panel3, BorderLayout.WEST);

        panel.add(panel2, BorderLayout.SOUTH);
    }

    if (noConfigDoneYet) {
        promptInputServer.run();
    }

    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Server konfigurieren",
            JOptionPane.OK_CANCEL_OPTION)) {
        if (syncService != null) {
            syncService.logoutIfLoggedIn();
        }
        iliasProperties.setIliasServerURL(serverAndClientId.getObjectA());
        iliasProperties.setIliasClient(serverAndClientId.getObjectB());
        iliasProperties.setLoginType((LoginType) comboboxLoginType.getSelectedItem());
        iliasProperties.setDownloadMethod((DownloadMethod) comboboxDownloadMethod.getSelectedItem());
        saveProperties(iliasProperties);
        updateTitleCaption();
    }

}

From source file:userinterface.Citizen.CitizenWorkAreaJPanel.java

private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
    int selectedRow = vitalSigntable.getSelectedRow();
    if (selectedRow >= 0) {
        int dialogButton = JOptionPane.YES_NO_OPTION;
        int dialogResult = JOptionPane.showConfirmDialog(null, "Would you like to delete Vital Sign?",
                "Warning", dialogButton);
        if (dialogResult == JOptionPane.YES_OPTION) {
            VitalSign vs = (VitalSign) vitalSigntable.getValueAt(selectedRow, 0);
            account.getCitizen().getHealthReport().deleteVitalSign(vs);
            populateTable();//from   w w w  . j  a v  a  2 s.c o  m
            resetfields();

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

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

private void loadFromFile(final File file) {
    if (file.isFile()) {

        try {//  www. j  ava2  s .  c  o m
            final FileContainer container = new FileContainer(file);
            loadState(container);
            updateTheSourceFile(file);
        } catch (Exception ex) {
            Log.error("Can't load map from file [" + file + ']', ex);
            JOptionPane.showMessageDialog(this, "Can't load file, may be wrong format", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else {
        Log.warn("Can't find file " + file);
        JOptionPane.showMessageDialog(this, "Can't find file " + file, "Can't find file",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:net.sf.jsignpdf.VisibleSignatureDialog.java

private void btnPreviewActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPreviewActionPerformed
    Integer pageNr = ConvertUtils.toInteger(tfPage.getText());
    if (pageNr != null) {
        btnPrevious.setEnabled(pageNr > 1);
        btnNext.setEnabled(pageNr < numberOfPages);
        // TODO progress bar or animated image... "yes, we are working..."
        if (pageNr <= 0 || pageNr > numberOfPages) {
            pageNr = numberOfPages;/*ww w . j  ava 2 s  .  c  o  m*/
        }
        final BufferedImage buffImg = p2i.getImageForPage(pageNr.intValue());
        if (buffImg != null) {
            final RelRect tmpRect = selectionImage.getRelRect();
            previewListenerDisabled = true;
            try {
                final Float[] coords = tmpRect.getCoords();
                coords[0] = Float.parseFloat(tfPosLLX.getText()) / pdfPageInfo.getWidth();
                coords[1] = Float.parseFloat(tfPosLLY.getText()) / pdfPageInfo.getHeight();
                coords[2] = Float.parseFloat(tfPosURX.getText()) / pdfPageInfo.getWidth();
                coords[3] = Float.parseFloat(tfPosURY.getText()) / pdfPageInfo.getHeight();
            } catch (Exception e) {
                e.printStackTrace();
            }
            selectionImage.setImage(buffImg);
            previewListenerDisabled = false;
            previewDialog.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(this, RES.get("error.vs.previewFailed"), "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(this, RES.get("error.vs.pageNotANumber"), "Error",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java

private void uplaodBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uplaodBtnActionPerformed

    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(null);//from w  w w .ja  v a 2s. c o m
    File f = chooser.getSelectedFile();
    if (f != null) {
        path = f.getAbsolutePath();
        if (path != null) {
            attachmentpath_Txt.setText(path);
        }
    } else {
        JOptionPane.showMessageDialog(null, "File not selected", "WARNING", JOptionPane.WARNING_MESSAGE);
    }

}