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:UI.MainUI.java

private void graphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphBtnActionPerformed
    int i = forecastTable.getRowCount();
    int l = 0, h = 0;
    if (i > 30) {
        String[] args = null;//from w  w  w.  ja v a 2s. c  om
        //        args[0] = (String)CurrencyComboBox.getSelectedItem();
        XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
        XYSeries dataset1 = new XYSeries("expected");
        XYSeries dataset2 = new XYSeries("actual");
        for (int j = 0; j < i; j++) {
            double f = Double.parseDouble((String) forecastTable.getValueAt(j, 2));
            double g = Double.parseDouble((String) forecastTable.getValueAt(j, 3));
            dataset1.add(j + 1, f);
            dataset2.add(j + 1, g);
        }
        xySeriesCollection.addSeries(dataset1);
        xySeriesCollection.addSeries(dataset2);
        switch (CurrencyComboBox.getSelectedIndex()) {
        case 0:
            l = 45;
            h = 75;
            break;
        case 1:
            l = 70;
            h = 110;
            break;
        case 2:
            l = 60;
            h = 100;
            break;
        case 3:
            l = 40;
            h = 80;
            break;
        }
        LineChart.main(args, xySeriesCollection, l, h);
    } else {
        String msg = "Forecast Exchange Rate First!!";
        JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
    } // TODO add your handling code here:
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java

/**
 * Undoes the most recent upload./*ww w  .  j av a 2s .  co  m*/
 * 
 * Called in response to undo command from user, and by the program when an upload is cancelled
 * or fails.
 */
public void undoUpload(final boolean isUserCmd, final boolean shuttingDown, final boolean completeUndo) {
    setOpKiller(null);

    final UploaderTask undoTask = new UploaderTask(false, "") {
        boolean success = false;
        boolean removeObjects = completeUndo;
        Vector<UploadTable> undone = new Vector<UploadTable>();

        @Override
        public Object doInBackground() {
            start();
            if (removeObjects) {
                try {
                    if (isUserCmd) {
                        SwingUtilities.invokeAndWait(new Runnable() {
                            public void run() {
                                initProgressBar(0, getUploadedObjects(), true,
                                        getResourceString("WB_UPLOAD_UNDOING") + " "
                                                + getResourceString("WB_UPLOAD_OBJECT"),
                                        shuttingDown);
                            }
                        });
                    } else {
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                initProgressBar(0, getUploadedObjects(), true,
                                        getResourceString("WB_UPLOAD_CLEANING_UP") + " "
                                                + getResourceString("WB_UPLOAD_OBJECT"),
                                        shuttingDown);
                            }
                        });
                    }
                    List<UploadTable> fixedUp = reorderUploadTablesForUndo();
                    boolean isEmbeddedCE = AppContextMgr.getInstance().getClassObject(Collection.class)
                            .getIsEmbeddedCollectingEvent();
                    undoAttachments();
                    try {
                        AppContextMgr.getInstance().getClassObject(Collection.class)
                                .setIsEmbeddedCollectingEvent(false);
                        for (int ut = fixedUp.size() - 1; ut >= 0; ut--) {
                            // setCurrentOpProgress(fixedUp.size() - ut, false);
                            logDebug("undoing " + fixedUp.get(ut).getTable().getName());
                            fixedUp.get(ut).undoUpload(true);
                            undone.add(fixedUp.get(ut));
                        }
                        success = true;
                        return success;
                    } finally {
                        AppContextMgr.getInstance().getClassObject(Collection.class)
                                .setIsEmbeddedCollectingEvent(isEmbeddedCE);
                    }
                } catch (Exception ex) {
                    setOpKiller(ex);
                    return false;
                }
            }
            //else
            success = true;
            return success;
        }

        @Override
        public void done() {
            if (removeObjects) {
                try {
                    for (UploadTable ut : undone) {
                        ut.finishUndoUpload();
                    }
                } catch (Exception ex) {
                    setOpKiller(ex);
                    success = false;
                }
            }

            super.done();

            if (removeObjects) {
                for (WorkbenchRow wbRow : theWb.getWorkbenchRows()) {
                    wbRow.setUploadStatus(WorkbenchRow.UPLD_NONE);
                }
                wbSS.setChanged(false);
            }

            statusBar.setText("");
            statusBar.setProgressDone("UPLOADER");
            if (shuttingDown) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        UIRegistry.clearSimpleGlassPaneMsg();

                    }
                });
            }
            if (getOpKiller() != null) {
                JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), String.format(
                        getResourceString("WB_UPLOAD_CLEANUP_FAILED"),
                        new Object[] {
                                getResourceString((isUserCmd ? "WB_UPLOAD_UNDO_BTN" : "WB_UPLOAD_CLEANUP")),
                                theWb.getName(), theWb.getName() }),
                        getResourceString("WARNING"), JOptionPane.WARNING_MESSAGE);

            }
            if (mainPanel != null) {
                mainPanel.clearObjectsCreated();
                if (success) {
                    if (removeObjects) {
                        setCurrentOp(Uploader.READY_TO_UPLOAD);
                    } else {
                        setCurrentOp(Uploader.SUCCESS_PARTIAL);
                    }
                } else {
                    setCurrentOp(Uploader.FAILURE);
                }
            }
            if (shuttingDown && !isUserCmd) {
                wbSS.decShutdownLock();
                wbSS.shutdown();
            }
        }

    };
    if (recordSets != null) {
        recordSets.clear();
        recordSets = null;
    }
    UIRegistry.displayStatusBarText(
            getResourceString((isUserCmd ? Uploader.UNDOING_UPLOAD : Uploader.CLEANING_UP)));
    if (shuttingDown) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                UIRegistry.writeSimpleGlassPaneMsg(
                        String.format(getResourceString("WB_UPLOAD_CLEANING_UP") + "...", theWb.getName()),
                        WorkbenchTask.GLASSPANE_FONT_SIZE);

            }
        });
    }
    if (shuttingDown && !isUserCmd) {
        wbSS.incShutdownLock();
    }
    undoTask.execute();
    setCurrentOp(isUserCmd ? Uploader.UNDOING_UPLOAD : Uploader.CLEANING_UP);
}

From source file:org.forester.archaeopteryx.TreePanel.java

final void reRoot(final PhylogenyNode node) {
    if (!getPhylogeny().isRerootable()) {
        JOptionPane.showMessageDialog(this, "This is not rerootable", "Not rerootable",
                JOptionPane.WARNING_MESSAGE);
        return;/*from   www. ja  va 2  s.  c  o m*/
    }
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) {
        JOptionPane.showMessageDialog(this, "Cannot reroot in unrooted display type",
                "Attempt to reroot tree in unrooted display", JOptionPane.WARNING_MESSAGE);
        return;
    }
    getPhylogeny().reRoot(node);
    getPhylogeny().recalculateNumberOfExternalDescendants(true);
    resetNodeIdToDistToLeafMap();
    resetPreferredSize();
    getMainPanel().adjustJScrollPane();
    repaint();
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR) {
        getControlPanel().showWhole();
    }
}

From source file:org.forester.archaeopteryx.TreePanel.java

final void subTree(final PhylogenyNode node) {
    if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) {
        JOptionPane.showMessageDialog(this, "Cannot get a sub/super tree in unrooted display",
                "Attempt to get sub/super tree in unrooted display", JOptionPane.WARNING_MESSAGE);
        return;//from ww  w .  j  av  a  2 s  . c  o m
    }
    if (node.isExternal()) {
        JOptionPane.showMessageDialog(this, "Cannot get a subtree of a external node",
                "Attempt to get subtree of external node", JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (node.isRoot() && (_subtree_index < 1)) {
        JOptionPane.showMessageDialog(this, "Cannot get a subtree of the root node",
                "Attempt to get subtree of root node", JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (!node.isExternal() && !node.isRoot() && (_subtree_index <= (TreePanel.MAX_SUBTREES - 1))) {
        _phylogenies[_subtree_index++] = _phylogeny;
        _phylogeny = _phylogeny.subTree(node);
        updateSubSuperTreeButton();
    } else if (node.isRoot() && (_subtree_index >= 1)) {
        superTree();
    }
    _main_panel.getControlPanel().showWhole();
    repaint();
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Load the provided file as an ontology replacing any assertions currently
 * in the assertions text area.//from   w w  w. j  a v a2  s  . c o m
 * 
 * @return The message to be presented on the status line
 */
private String loadOntologyFile() {
    final int chunkSize = 32000;
    StringBuilder allData;
    char[] chunk;
    long totalBytesRead = 0;
    int chunksRead = 0;
    int maxChunks;
    int bytesRead = -1;
    ProgressMonitor monitor = null;
    Reader reader = null;
    String message;
    boolean loadCanceled = false;

    if (rdfFileSource.isFile()) {
        lastDirectoryUsed = rdfFileSource.getBackingFile().getParentFile();
    }

    assertionsInput.setText("");
    invalidateModel(false);

    allData = new StringBuilder();
    chunk = new char[chunkSize];

    setStatus("Loading file " + rdfFileSource.getAbsolutePath());

    if (rdfFileSource.length() > 0 && rdfFileSource.length() < MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) {
        maxChunks = (int) (rdfFileSource.length() / chunkSize);
    } else {
        maxChunks = (int) (MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA / chunkSize);
    }

    if (rdfFileSource.length() % chunkSize > 0) {
        ++maxChunks;
    }

    // Assume the file can be loaded
    hasIncompleteAssertionsInput = false;

    monitor = new ProgressMonitor(this, "Loading assertions from " + rdfFileSource.getName(), "0 bytes read", 0,
            maxChunks);

    try {
        reader = new InputStreamReader(rdfFileSource.getInputStream());
        while (!loadCanceled && (rdfFileSource.isUrl() || chunksRead < maxChunks)
                && (bytesRead = reader.read(chunk)) > -1) {
            totalBytesRead += bytesRead;

            chunksRead = (int) (totalBytesRead / chunk.length);

            if (chunksRead < maxChunks) {
                allData.append(chunk, 0, bytesRead);
            }

            if (chunksRead >= maxChunks) {
                monitor.setMaximum(chunksRead + 1);
            }

            monitor.setProgress(chunksRead);
            monitor.setNote("Read " + INTEGER_COMMA_FORMAT.format(totalBytesRead)
                    + (rdfFileSource.isFile() ? " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length())
                            : " bytes")
                    + (chunksRead >= maxChunks ? " (Determining total file size)" : ""));

            loadCanceled = monitor.isCanceled();
        }

        if (!loadCanceled && rdfFileSource.isUrl()) {
            rdfFileSource.setLength(totalBytesRead);
        }

        if (!loadCanceled && rdfFileSource.length() > MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA) {
            // The entire file was not loaded
            hasIncompleteAssertionsInput = true;
        }

        if (hasIncompleteAssertionsInput) {
            StringBuilder warningMessage;

            warningMessage = new StringBuilder();
            warningMessage.append("The file is too large to display. However the entire file will be loaded\n");
            warningMessage.append("into the model when it is built.\n\nDisplay size limit (bytes): ");
            warningMessage.append(INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA));
            if (rdfFileSource.isFile()) {
                warningMessage.append("\nFile size (bytes):");
                warningMessage.append(INTEGER_COMMA_FORMAT.format(rdfFileSource.length()));
            }
            warningMessage.append("\n\n");
            warningMessage.append("Note that the assersions text area will not permit editing\n");
            warningMessage.append("of the partially loaded file and the 'save assertions' menu\n");
            warningMessage.append("option will be disabled. These limitations are enabled\n");
            warningMessage.append("to prevent the accidental loss of information from the\n");
            warningMessage.append("source assertions file.");

            JOptionPane.showMessageDialog(this, warningMessage.toString(), "Max Display Size Reached",
                    JOptionPane.WARNING_MESSAGE);

            // Add text to the assertions text area to highlight the fact that the
            // entire file was not loaded into the text area
            allData.insert(0,
                    "# First " + INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA)
                            + " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length())
                            + " bytes displayed\n\n");
            allData.insert(0, "# INCOMPLETE VERSION of the file: " + rdfFileSource.getAbsolutePath() + "\n");
            allData.append("\n\n# INCOMPLETE VERSION of the file: " + rdfFileSource.getAbsolutePath() + "\n");
            allData.append("# First " + INTEGER_COMMA_FORMAT.format(MAX_ASSERTION_BYTES_TO_LOAD_INTO_TEXT_AREA)
                    + " of " + INTEGER_COMMA_FORMAT.format(rdfFileSource.length()) + " bytes displayed\n");
        }

        // Set the loaded assertions into the text area, cleaning up Windows \r\n
        // endings, if found
        if (!loadCanceled) {
            assertionsInput.setText(allData.toString().replaceAll("\r\n", "\n"));
            assertionsInput.setSelectionEnd(0);
            assertionsInput.setSelectionStart(0);
            assertionsInput.moveCaretPosition(0);
            assertionsInput.scrollRectToVisible(new Rectangle(0, 0, 1, 1));

            message = "Loaded file" + (hasIncompleteAssertionsInput ? " (incomplete)" : "") + ": "
                    + rdfFileSource.getName();
            addRecentAssertedTriplesFile(rdfFileSource);

            // Select the assertions tab
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    tabbedPane.setSelectedIndex(TAB_NUMBER_ASSERTIONS);
                    setFocusOnCorrectTextArea();
                }
            });
        } else {
            message = "Assertions file load canceled by user";
        }
    } catch (Throwable throwable) {
        setStatus("Unable to load file: " + rdfFileSource.getName());
        JOptionPane.showMessageDialog(this, "Error: Unable to read file\n\n" + rdfFileSource.getAbsolutePath()
                + "\n\n" + throwable.getMessage(), "Error Reading File", JOptionPane.ERROR_MESSAGE);
        LOGGER.error("Unable to load the file: " + rdfFileSource.getAbsolutePath(), throwable);
        message = "Unable to load the file: " + rdfFileSource.getAbsolutePath();
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Throwable throwable) {
                LOGGER.error("Unable to close input file", throwable);
            }
        }

        if (monitor != null) {
            monitor.close();
        }
    }

    return message;
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Determine whether an output file already exists and if so, popup a dialog
 * asking they user whether it is okay to overwrite the existing file.
 * /*from   w  w  w .  j a  v  a  2  s.c o  m*/
 * @param destinationFile
 *          The output file
 * 
 * @return True of the file may be written (overwritten)
 */
private boolean okToOverwriteFile(File destinationFile) {
    boolean okayToWrite = !destinationFile.exists();
    if (!okayToWrite) {
        int verifyOverwrite;
        verifyOverwrite = JOptionPane.showConfirmDialog(this,
                "The file exists: " + destinationFile.getName() + "\n\nOkay to overwrite?", "Overwrite File?",
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        okayToWrite = verifyOverwrite == JOptionPane.YES_OPTION;
    }

    return okayToWrite;
}

From source file:com.osparking.osparking.Settings_System.java

private void tryToCloseSettingsForm() {
    if (SettingsSaveButton.isEnabled()) {
        JOptionPane.showMessageDialog(this, "Settings Changed.\n \n" + "Either [Save] or [Cancel], please.",
                "Confirm Request", JOptionPane.WARNING_MESSAGE);
        this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    } else {/*from   ww  w  .  j a  va  2  s .c o  m*/
        if (mainForm != null) {
            mainForm.getTopForms()[TopForms.Settings.ordinal()] = null;
        }

        if (isStand_Alone) {
            this.setVisible(false);
            System.exit(0);
        } else {
            dispose();
        }
    }
}

From source file:com.osparking.osparking.Settings_System.java

private void showWarningReallyHere(int gateID, DeviceType type) {
    String msg = CHECK_IP_DIALOG_1.getContent() + System.lineSeparator() + System.lineSeparator() + " -"
            + DEV_CONN_ERROR_2.getContent() + GATE_NAME_LABEL.getContent() + gateID + System.lineSeparator()
            + " -" + DEV_CONN_ERROR_3.getContent() + type.getContent() + "#" + gateID + System.lineSeparator()
            + System.lineSeparator() + CHECK_IP_DIALOG_4.getContent();

    JOptionPane.showMessageDialog(this, msg, Blackfly + " " + CHECK_IP_TITLE.getContent(),
            JOptionPane.WARNING_MESSAGE);
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Ask the user whether to save unsaved information to a file.
 * /*from w  w w.  j  a  v  a 2 s.  c  o m*/
 * @param description
 *          The description of the information to be saved. It should be
 *          written in the singular.
 * 
 * @return True if the user wants to save the information to a file
 */
private boolean checkWhetherToSaveFile(String description) {
    return JOptionPane.showConfirmDialog(this,
            "The " + description + " has not been saved.\n\n" + "Do you want to save it?",
            "Unsaved Changes: " + description, JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION;
}

From source file:interfaces.InterfazPrincipal.java

private void botonEstablecerMontoFacturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonEstablecerMontoFacturaActionPerformed
    // TODO add your handling code here:
    int seleccion = JOptionPane.showConfirmDialog(this,
            "Al establecer un monto de factura, no se considerarn los productos en ella \n Desea continuar?",
            "Mensaje del sistema", JOptionPane.YES_NO_OPTION);
    if (seleccion == 0) {

        try {/*from   w w  w .j  a  va 2 s  .  c  o m*/
            double monto = Double.parseDouble(valorMontoFactura.getText());

            if (monto <= 0.0) {
                throw new Exception();

            }
            valorActualFactura.setText(valorMontoFactura.getText());

            DefaultTableModel modeloTabla = (DefaultTableModel) TablaDeFacturaProducto.getModel();

            //Borrar filas
            for (int i = 0; i < modeloTabla.getRowCount(); i++) {
                modeloTabla.removeRow(i);
            }
            modeloTabla.setRowCount(0);

            TablaDeFacturaProducto.setModel(modeloTabla);
            botonAgregarProducto.setEnabled(false);

        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "El valor debe ser numrico positivo", "Advertencia",
                    JOptionPane.WARNING_MESSAGE);
        }

    }

}