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:de.cebitec.readXplorer.differentialExpression.plot.DeSeq2GraphicsTopComponent.java

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
    ReadXplorerFileChooser fc = new ReadXplorerFileChooser(new String[] { "svg" }, "svg") {
        private static final long serialVersionUID = 1L;

        @Override//from  ww  w  .java  2s  .  c o m
        public void save(String fileLocation) {
            ProgressHandle progressHandle = ProgressHandleFactory
                    .createHandle("Save plot to svg file: " + fileLocation);
            Path to = FileSystems.getDefault().getPath(fileLocation, "");
            DeSeq2AnalysisHandler.Plot selectedPlot = (DeSeq2AnalysisHandler.Plot) plotType.getSelectedItem();
            Path from = currentlyDisplayed.toPath();
            try {
                Path outputFile = Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
                messages.setText("SVG image saved to " + outputFile.toString());
            } catch (IOException ex) {
                Date currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
                Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "{0}: " + ex.getMessage(),
                        currentTimestamp);
                JOptionPane.showMessageDialog(null, ex.getMessage(), "Could not write to file.",
                        JOptionPane.WARNING_MESSAGE);
            } finally {
                progressHandle.switchToDeterminate(100);
                progressHandle.finish();
            }

        }

        @Override
        public void open(String fileLocation) {
        }
    };
    fc.openFileChooser(ReadXplorerFileChooser.SAVE_DIALOG);
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java

/**
 *
 * @param directory//from w  w w  .j a v a 2  s  .c o m
 * @param reportName
 * @return
 */
private File createPdfFile(File directory, String fileName, JFreeChart chart) {
    File pdfFile = new File(directory, fileName);
    if (fileName.endsWith(".pdf")) {
        tryToCreateFile(pdfFile, chart);
    } else {
        singleCellPreProcessingController.showMessage("Please use .pdf extension for the file.",
                "extension file problem", JOptionPane.WARNING_MESSAGE);
        // retry to create pdf file
        try {
            createPdf(chart);
        } catch (IOException ex) {
            LOG.error(ex.getMessage(), ex);
            singleCellPreProcessingController.showMessage("An error occurred: " + ex.getMessage(),
                    "unexpected error", JOptionPane.ERROR_MESSAGE);
        }
    }
    return pdfFile;
}

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

private void loadReadingsButtonActionPerformed(ActionEvent e) {
    if (ReaderContext.isFoxberryConnected() || (ReaderContext.isUsbConnected())) {
        JLoadTimeReadings loadReadings = new JLoadTimeReadings();
        loadReadings.setVisible(true);/*from  w w w  . ja v  a  2 s  .c  o m*/
    } else {
        JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:StoreAdmin.ManageStoreJPanel.java

private void btnaddtocartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddtocartActionPerformed
    // Store s= (Store)cmbstorelist.getSelectedItem();
    int selectedRow = tblProductDetails.getSelectedRow();
    Product selectedProduct;/*from   w w w  . j  a  va2 s.  c  om*/
    int salesPrice = 0;

    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(this, "Select a row", "Warning", JOptionPane.WARNING_MESSAGE);
        return;
    } else {
        selectedProduct = (Product) tblProductDetails.getValueAt(selectedRow, 0);
    }
    if (s == null) {

        JOptionPane.showMessageDialog(this, "Please create a store", "Warning", JOptionPane.WARNING_MESSAGE);
        return;

    } else {

        try {
            salesPrice = Integer.parseInt(txtsalesprice.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Enter valid sales price", "Warning",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (salesPrice < selectedProduct.getMarkedPrice()) {
            JOptionPane.showMessageDialog(this, "Sales Price should be more than Marked Price", "Warning",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }

        int fetchedQty = (Integer) quantitySpinner.getValue();
        if (fetchedQty <= 0) {
            JOptionPane.showMessageDialog(this, "Selected atlest 1 quantity", "Warning",
                    JOptionPane.WARNING_MESSAGE);
            return;
        } else if (fetchedQty <= selectedProduct.getAvailability()) {
            boolean alreadyPresent = false;

            for (Product p : s.getInventoryDirectory().getInventoryList()) {
                if (p.getProductName() == selectedProduct.getProductName()) {
                    int oldAvail = selectedProduct.getAvailability();
                    int newAvail = oldAvail - fetchedQty;
                    selectedProduct.setAvailability(newAvail);
                    p.setAvailability(fetchedQty + p.getAvailability());
                    p.setQuantity(fetchedQty + p.getQuantity());
                    p.setSellingPrice(Double.parseDouble(txtsalesprice.getText().trim()));
                    alreadyPresent = true;
                    refreshOrderTable();
                    populateProductTable();
                    break;
                }
            }

            if (!alreadyPresent) {
                int oldAvail = selectedProduct.getAvailability();
                int newAvail = oldAvail - fetchedQty;
                selectedProduct.setAvailability(newAvail);
                Product p = new Product();
                p.setProductID(selectedProduct.getProductID());
                p.setProductName(selectedProduct.getProductName());
                p.setAvailability(fetchedQty);
                p.setSellingPrice(Double.parseDouble(txtsalesprice.getText().trim()));
                p.setQuantity(fetchedQty);
                s.getInventoryDirectory().addProductinInventory(p);
                refreshOrderTable();
                populateProductTable();
            }
        } else {
            JOptionPane.showMessageDialog(this, "Quantity > Availability!!", "Warning",
                    JOptionPane.WARNING_MESSAGE);

        }

    }
}

From source file:UserInterface.PatientRole.ManageMyVitalSignsAndFitnessRecordJPanel.java

private void viewJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewJButtonActionPerformed
    // TODO add your handling code here:
    int selectedRow = viewVitalSignsJTable1.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Please select a row from the table first to view detail",
                "Warning", JOptionPane.WARNING_MESSAGE);

    } else {/*from  w  w w . java 2 s .  c  o  m*/

        Record vs = (Record) viewVitalSignsJTable1.getValueAt(selectedRow, 0);
        ViewUpdateRecordDetailsJPanel panel = new ViewUpdateRecordDetailsJPanel(userProcessContainer,
                userAccount, patientOrganization, enterprise, ecoSystem, vs);
        userProcessContainer.add("ViewUpdateRecordDetailsJPanel", panel);
        CardLayout layout = (CardLayout) userProcessContainer.getLayout();
        layout.next(userProcessContainer);

    }

}

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

private void countTagsButtonActionPerformed(ActionEvent e) {
    if (ReaderContext.isFoxberryConnected()) {
        JCountTags countTags = new JCountTags(this);
        countTags.setVisible(true);/*from  w ww . j av a2 s . c  o  m*/
    } else {
        JOptionPane.showConfirmDialog(this, "Se debe conectar a un lector primero", "Sin conexin a lectores",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:localization.SplitterUI.java

private void logActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logActionPerformed
    // TODO add your handling code here:
    String folderpath = filepath.getText();
    if (folderpath.length() > 0 && (folderpath.endsWith(".lpu") || folderpath.endsWith(".zip"))) {
        String logfile = folderpath.substring(0, folderpath.lastIndexOf(".")) + ".log";
        File folder = new File(logfile);
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(folder);
            } catch (IOException ex) {
                Logger.getLogger(SplitterUI.class.getName()).log(Level.SEVERE, null, ex);
            }/*  ww w .  j ava2  s.c o m*/
        }
    } else if (folderpath.length() > 0) {
        JOptionPane.showMessageDialog(this, "Since you have input a folder path, you need to open it manually.",
                "Open Log File Warning", JOptionPane.WARNING_MESSAGE, null);
        return;
    } else {
        String home = System.getProperty("user.home") + "\\Desktop";
        File folder = new File(home);
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(folder);
            } catch (IOException ex) {
                Logger.getLogger(SplitterUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}

From source file:com.t3.client.TabletopTool.java

/**
 * This method is specific to deleting a token, but it can be used as a
 * basis for any other method which wants to be turned off via a property.
 * //w  w  w . j  a v  a 2  s . c  o m
 * @return true if the token should be deleted.
 */
public static boolean confirmTokenDelete() {
    if (!AppPreferences.getTokensWarnWhenDeleted()) {
        return true;
    }

    String msg = I18N.getText("msg.confirm.deleteToken");
    log.debug(msg);
    Object[] options = { I18N.getText("msg.title.messageDialog.yes"),
            I18N.getText("msg.title.messageDialog.no"), I18N.getText("msg.title.messageDialog.dontAskAgain") };
    String title = I18N.getText("msg.title.messageDialogConfirm");
    int val = JOptionPane.showOptionDialog(clientFrame, msg, title, JOptionPane.NO_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);

    // "Yes, don't show again" Button
    if (val == 2) {
        showInformation("msg.confirm.deleteToken.removed");
        AppPreferences.setTokensWarnWhenDeleted(false);
    }
    // Any version of 'Yes'...
    if (val == JOptionPane.YES_OPTION || val == 2) {
        return true;
    }
    // Assume 'No' response
    return false;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java

/**
 * @param pdfFile// w  w w .  j  a v a 2s  .  c  om
 */
private void tryToCreateFile(File pdfFile, JFreeChart chart) {
    try {
        boolean success = pdfFile.createNewFile();
        if (success) {
            singleCellPreProcessingController.showMessage("Chart saved to file!", "chart saved OK",
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            Object[] options = { "Yes", "No", "Cancel" };
            int showOptionDialog = JOptionPane.showOptionDialog(null,
                    "File already exists. Do you want to replace it?", "", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[2]);
            // if YES, user wants to delete existing file and replace it
            if (showOptionDialog == 0) {
                boolean delete = pdfFile.delete();
                if (!delete) {
                    return;
                }
                // if NO, returns already existing file
            } else if (showOptionDialog == 1) {
                return;
            }
        }
    } catch (IOException ex) {
        singleCellPreProcessingController.showMessage("Unexpected error: " + ex.getMessage() + ".",
                "Unexpected error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    try (FileOutputStream fileOutputStream = new FileOutputStream(pdfFile)) {
        // actually create PDF file
        createPdfFile(fileOutputStream, chart);
    } catch (IOException ex) {
        singleCellPreProcessingController.showMessage("Unexpected error: " + ex.getMessage() + ".",
                "Unexpected error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.doctype.ferramentaDoctype.java

public void avaliaUrl(String url) {
    PegarPaginaWEB ppw = new PegarPaginaWEB();
    if (url != null) {
        try {/*w w  w .  ja v  a  2 s .  c  om*/
            String codHtml = ppw.getContent(url);
            TxtBuffer.setContentOriginal(codHtml, "0");
            controla(codHtml);
            this.painelOriginal.controla(codHtml);
        } 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);
        }
    }
}