Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane ERROR_MESSAGE.

Prototype

int ERROR_MESSAGE

To view the source code for javax.swing JOptionPane ERROR_MESSAGE.

Click Source Link

Document

Used for error messages.

Usage

From source file:au.org.ala.delta.intkey.ui.RealInputDialog.java

@Override
void handleBtnImagesClicked() {
    CharacterImageDialog dlg = new CharacterImageDialog(this,
            Arrays.asList(new au.org.ala.delta.model.Character[] { _ch }), null, _imageSettings, true, true,
            _imagesStartScaled);/*ww  w .j a va 2s. c  o  m*/
    dlg.displayImagesForCharacter(_ch);
    ((SingleFrameApplication) Application.getInstance()).show(dlg);

    try {
        FloatRange rangeFromImageDialog = dlg.getInputRealValues();
        if (rangeFromImageDialog != null) {
            _inputData = rangeFromImageDialog;
            _okPressed = true;
            this.setVisible(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, validationErrorMessage, validationErrorTitle,
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:ru.develgame.jflickrorganizer.MainClass.java

@Bean
public Properties jFlickrOrganizerProperties() {
    String propertiesFile = "src/main/resources/setup.properties";
    Properties properties = null;
    try (FileInputStream fis = new FileInputStream(propertiesFile)) {
        properties = new Properties();
        properties.load(new FileInputStream(propertiesFile));
    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null, LocaleMessages.getMessage("Authorizer.Error.PropertyFileNotFound"),
                LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, LocaleMessages.getMessage("Authorizer.Error.PropertyFileNotFound"),
                LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
    }/*from   ww  w  .ja va  2 s . co m*/

    return properties;
}

From source file:net.sf.webphotos.util.Util.java

/**
 * Retorna o diretrio raiz de albuns. Checa se a varivel albunsRoot j
 * possui o valor, caso no, busca o arquivo nas propriedades atravs do
 * mtodo//from   w  w  w  . ja v a 2 s  .co m
 * {@link net.sf.webphotos.util.Util#getProperty(String) getProperty}(String
 * chave) e faz um teste para checar se  um diretrio mesmo. Caso tudo
 * esteja correto, retorna o diretrio.
 *
 * @return Retorna um diretrio.
 */
public static File getAlbunsRoot() {
    if (albunsRoot == null) {
        albunsRoot = new File(getProperty("albunsRoot"));
        if (!albunsRoot.isDirectory()) {
            StringBuilder errMsg = new StringBuilder();
            errMsg.append("O diretrio fornecido no parmetro albunsRoot (arquivo de configurao)\n");
            errMsg.append("no pode ser utilizado, ou no existe.\n");
            errMsg.append("O programa ser encerrado.");
            JOptionPane.showMessageDialog(null, errMsg.toString(), "Erro no arquivo de configurao",
                    JOptionPane.ERROR_MESSAGE);
            //throw new RuntimeException(errMsg.toString());
            System.exit(-1);
        }
    }
    return albunsRoot;
}

From source file:com.clank.launcher.swing.SwingHelper.java

/**
 * Shows an popup error dialog, with potential extra details shown either immediately
 * or available on the dialog.//from  ww w.  jav a 2s  . co m
 *
 * @param parentComponent the frame from which the dialog is displayed, otherwise
 *                        null to use the default frame
 * @param message the message to display
 * @param title the title string for the dialog
 * @param throwable the exception, or null if there is no exception to show
 * @see #showMessageDialog(java.awt.Component, String, String, String, int) for details
 */
public static void showErrorDialog(Component parentComponent, @NonNull String message, @NonNull String title,
        Throwable throwable) {
    String detailsText = null;

    // Get a string version of the exception and use that for
    // the extra details text
    if (throwable != null) {
        StringWriter sw = new StringWriter();
        throwable.printStackTrace(new PrintWriter(sw));
        detailsText = sw.toString();
    }

    showMessageDialog(parentComponent, message, title, detailsText, JOptionPane.ERROR_MESSAGE);
}

From source file:edu.harvard.mcz.imagecapture.ThumbnailBuilder.java

@Override
public void run() {
    int existsCounter = 0;
    // mkdir thumbs ; mogrify -path thumbs -resize 80x120 *.JPG                   
    if (startPoint.isDirectory() && (!startPoint.getName().equals("thumbs"))) {
        File thumbsDir = new File(startPoint.getPath() + File.separator + "thumbs");
        log.debug(thumbsDir.getPath());//from   w w  w .  j  a  va  2  s . co  m
        if (!thumbsDir.exists()) {
            thumbsDir.mkdir();
            thumbsDir.setWritable(true);
            log.debug("Creating " + thumbsDir.getPath());
        }
        File[] potentialFilesToThumb = startPoint.listFiles();
        List<File> filesToThumb = new ArrayList<File>();
        int filesToThumbCount = 0;
        for (int i = 0; i < potentialFilesToThumb.length; i++) {
            if (potentialFilesToThumb[i].getName().endsWith(".JPG")) {
                filesToThumb.add(potentialFilesToThumb[i]);
                filesToThumbCount++;
            }
        }
        if (filesToThumbCount > 0) {
            int targetWidth = 100;
            int targetHeight = 150;

            Iterator<File> i = filesToThumb.iterator();
            while (i.hasNext()) {
                File file = i.next();
                File output = new File(thumbsDir.getPath().concat(File.separator).concat(file.getName()));
                if (!output.exists()) {
                    // don't overwrite existing thumnails
                    try {
                        BufferedImage img = ImageIO.read(file);
                        BufferedImage thumbnail = Scalr.resize(img, Scalr.Method.BALANCED,
                                Scalr.Mode.FIT_TO_WIDTH, targetWidth, targetHeight, Scalr.OP_ANTIALIAS);
                        // img.createGraphics().drawImage(ImageIO.read(file).getScaledInstance(targetWidth, targetHeigh, Image.SCALE_SMOOTH),0,0,null);
                        ImageIO.write(thumbnail, "jpg", output);
                        thumbnailCounter++;
                    } catch (IOException e1) {
                        log.error(e1.getMessage(), e1);
                        JOptionPane.showMessageDialog(null, e1.getMessage() + "\n", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                } else {
                    existsCounter++;
                }
            }

        } else {
            String message = "No *.JPG files found in " + startPoint.getPath();
            log.debug(message);
        }
    }
    String exists = "";
    if (existsCounter > 0) {
        exists = "\nSkipped " + existsCounter + " existing thumbnails.";
    }
    JOptionPane.showMessageDialog(null,
            "Done building " + thumbnailCounter + " thumbnails in ./thumbs/" + exists, "Thumbnails Built.",
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:com.mindcognition.mindraider.ui.swing.dialogs.UpdateOutlineJDialog.java

protected void updateNotebook() {
    // update name
    if ("".equals(outlineTitle.getText())) {
        JOptionPane.showMessageDialog(this, Messages.getString("NewNotebookJDialog.notebookNameCannotBeEmpty"),
                Messages.getString("NewNotebookJDialog.notebookCreationError"), JOptionPane.ERROR_MESSAGE);
        return;/*from  ww w .  j  av a 2s .  c  om*/
    } else {
        if (!oldNotebookDescriptor.getLabel().equals(outlineTitle.getText())) {
            try {
                MindRaider.labelCustodian.renameNotebook(oldNotebookDescriptor.getUri(),
                        outlineTitle.getText());
            } catch (Exception e) {
                logger.error("Unable to rename notebook", e);
            }
        }
    }

    // update labels
    try {
        // notebook URI can not be changed

        // process labels - create new for every unknown
        String text = outlineLabels.getText();
        if (text != null && text.length() > 0) {
            // method:
            // - put all old labels to the hashset
            // - on update:
            //  - remove from hashset tags which stayed unchanged
            //  - if tag remained in hashset, it must be deleted
            //  - if new tag is not in hashset, it must be created

            String[] labelsArray = text.split(",");
            for (String labelLabel : labelsArray) {
                labelLabel = labelLabel.trim();
                if (labelLabel != null && labelLabel.length() > 0) {
                    String labelNcName = Utils.toNcName(labelLabel);
                    logger.debug(" New label: " + labelLabel + " # " + labelNcName);

                    // remove labels which were not changed from the old labels -> in 
                    // hashset will remain just labels to be removed
                    if (oldLabels.containsKey(labelLabel)) {
                        oldLabels.remove(labelLabel);
                    } else {
                        // label must be created
                        String labelUri = MindRaiderVocabulary.getFolderUri(labelNcName);
                        if (!MindRaider.labelCustodian.exists(labelUri)) {
                            MindRaider.labelCustodian.create(labelLabel, labelUri);
                        }

                        MindRaider.labelCustodian.addOutline(labelUri, oldNotebookDescriptor.getUri());
                    }
                }
            }
        } else {
            // create "all" label, if notebook has no labels
            String allLabelUri = MindRaiderVocabulary.getFolderUri("all");
            if (!MindRaider.labelCustodian.exists(allLabelUri)) {
                MindRaider.labelCustodian.create("all", allLabelUri);
            }
            MindRaider.labelCustodian.addOutline(allLabelUri, oldNotebookDescriptor.getUri());
        }

        // remove notebook from the folders where it no longer is
        if (oldLabels.size() > 0) {
            Iterator<ResourceDescriptor> remainingOldLabels = oldLabels.values().iterator();
            while (remainingOldLabels.hasNext()) {
                ResourceDescriptor labelDescriptor = remainingOldLabels.next();
                // remove
                MindRaider.labelCustodian.discardOutlineFromLabel(labelDescriptor.getUri(),
                        oldNotebookDescriptor.getUri(), false);
            }
        }

        ExplorerJPanel.getInstance().refresh();
    } catch (Exception e) {
        logger.error("updateNotebook()", e);
        JOptionPane.showMessageDialog(this, Messages.getString("NewNotebookJDialog.notebookCreationError"),
                Messages.getString("NewNotebookJDialog.unableToCreateNotebook", e.getMessage()),
                JOptionPane.ERROR_MESSAGE);
    }
    UpdateOutlineJDialog.this.dispose();
}

From source file:com.antelink.sourcesquare.gui.controller.ExitController.java

public void bind() {

    this.view.getOpenButtonLabel().addMouseListener(new MouseListener() {

        @Override// www. j  a  va2 s . c o m
        public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseClicked(MouseEvent arg0) {
            try {
                Desktop.getDesktop().browse(new URI("http://localhost:9524/"));
            } catch (IOException e) {
                logger.error("Error opening the browser", e);
            } catch (URISyntaxException e) {
                logger.error("Error opening the browser", e);
            }
        }
    });

    this.eventBus.addHandler(StartScanEvent.TYPE, new StartScanEventHandler() {

        @Override
        public String getId() {
            return "Exit Controller is now Handling";
        }

        @Override
        public void handle(File toScan) {
            display();
        }
    });
    this.eventBus.addHandler(ErrorEvent.TYPE, new ErrorEventHandler() {

        @Override
        public String getId() {
            return "Handling error";
        }

        @Override
        public void handle(String error) {
            JOptionPane.showMessageDialog(ExitController.this.view, error, null, JOptionPane.ERROR_MESSAGE);
            System.exit(0);
        }
    });

}

From source file:dk.dma.epd.ship.gui.route.WptTableModel.java

@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    RouteWaypoint wpt = route.getWaypoints().get(rowIndex);
    RouteLeg outLeg = wpt.getOutLeg();/*from  w  ww .j a  v a  2 s . c  o m*/

    try {
        switch (columnIndex) {
        case 0:
            wpt.setName((String) aValue);
            break;
        case 1:
            wpt.setPos(wpt.getPos().withLatitude(parseLat((String) aValue)));
            break;
        case 2:
            wpt.setPos(wpt.getPos().withLongitude(parseLon((String) aValue)));
            break;
        case 5:
            String head = (String) aValue;
            if (head != null && head.equalsIgnoreCase("GC")) {
                outLeg.setHeading(Heading.GC);
            } else {
                outLeg.setHeading(Heading.RL);
            }
            break;
        case 6:
            wpt.setTurnRad(parseDouble((String) aValue));
            break;
        case 8:
            outLeg.setXtdPort(parseDouble((String) aValue) / 1852.0);
            break;
        case 9:
            outLeg.setXtdStarboard(parseDouble((String) aValue) / 1852.0);
            break;
        case 10:
            outLeg.setSpeed(parseDouble((String) aValue));
            break;
        }

    } catch (FormatException e) {
        JOptionPane.showMessageDialog(this.dialog, "Error in entered value", "Input error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    if (route instanceof ActiveRoute) {
        ActiveRoute activeRoute = (ActiveRoute) route;
        activeRoute.calcValues(true);
        routeManager.changeActiveWp(activeRoute.getActiveWaypointIndex());
    } else {
        route.calcValues(true);
        routeManager.notifyListeners(RoutesUpdateEvent.ROUTE_CHANGED);
    }
    fireTableDataChanged();
}

From source file:com.emental.mindraider.ui.dialogs.DownloadModelJDialog.java

/**
 * Upload the model.// w w w  .j  a  v a  2 s.  co  m
 */
protected void upload() {
    String modelUrl = (String) modelUrlCombo.getSelectedItem();
    if (StringUtils.isEmpty(modelUrl)) {
        StatusBar.show(Messages.getString("DownloadModelJDialog.invalidModelLocation"), Color.RED);
    } else {
        try {
            MindRaider.spidersGraph.load(modelUrl);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, Messages.getString("DownloadModelJDialog.loadModelError"),
                    Messages.getString("DownloadModelJDialog.unableToLoadModel", e.getMessage()),
                    JOptionPane.ERROR_MESSAGE);
            return;
        }
        StatusBar.show(Messages.getString("DownloadModelJDialog.modelDownloaded", modelUrl));
    }
    dispose();
}

From source file:edu.harvard.mcz.imagecapture.jobs.JobFileReconciliation.java

private void reconcileFiles() {
    // find the place to start
    File imagebase = null; // place to start the scan from, imagebase directory for SCAN_ALL
    File startPoint = null;//from  w  w  w . j av  a2 s.com
    // If it isn't null, retrieve the image base directory from properties, and test for read access.
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_IMAGEBASE) == null) {
        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                "Can't start scan.  Don't know where images are stored.  Set imagbase property.", "Can't Scan.",
                JOptionPane.ERROR_MESSAGE);
    } else {
        imagebase = new File(Singleton.getSingletonInstance().getProperties().getProperties()
                .getProperty(ImageCaptureProperties.KEY_IMAGEBASE));
        if (imagebase != null) {
            if (imagebase.canRead()) {
                startPoint = imagebase;
                // recurse through directory tree from place to start
                checkFiles(startPoint, resultCounter);
            }
        }
    }
}