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:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * Attach the selected resource./*from  w  w  w  .j a va  2  s . c  o  m*/
 */
void attach() {
    String attachUrl;

    if (webType.isSelected()) {
        attachUrl = urlTextField.getText();
    } else {
        attachUrl = pathTextField.getText();
    }

    if (StringUtils.isEmpty(attachUrl)) {
        JOptionPane.showMessageDialog(MindRaider.mainJFrame,
                Messages.getString("AttachmentJDialog.errorMessage"),
                Messages.getString("AttachmentJDialog.error"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    try {
        String txt = description.getText();
        if (StringUtils.isEmpty(txt)) {
            txt = attachUrl;
        }
        MindRaider.noteCustodian.addAttachment(conceptResource, new AttachmentResource(txt, attachUrl), true);
    } catch (Exception e) {
        logger.debug(Messages.getString("AttachmentJDialog.unableToAttachResource",
                new Object[] { attachUrl, e.getMessage() }));
    }
    StatusBar.show(Messages.getString("AttachmentJDialog.attachedWebResource", attachUrl));
    OutlineJPanel.getInstance().conceptJPanel.refresh();
    dispose();
}

From source file:EditorPaneExample15.java

public void loadNewPage(Object page) {
    try {//from  w  ww.j  a va 2  s.com
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);

            // Modify styles for this document only
            modifyStyleSheet(doc.getStyleSheet());

            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));
            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableInput();
        loadingPage = false;
    }
}

From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java

public static boolean removeVOFromFavourites(String voName) {
    boolean isRemoved = false;
    TreeMap allFavVOs = getVOGroup(FAVOURITES);
    Iterator<Map.Entry<String, TreeMap>> entries = allFavVOs.entrySet().iterator();
    while (entries.hasNext()) {
        Map.Entry<String, TreeMap> entry = entries.next();
        String vonameinMap = entry.getKey();
        if (voName.equals(vonameinMap)) {
            //Check also if it is a self-VO, if yes, need to remove folders too
            TreeMap allEGIVOs = getVOGroup(EGI);
            TreeMap allOTHERSVO = getVOGroup(OTHERS);
            if (!allEGIVOs.containsKey(voName) && !allOTHERSVO.containsKey(voName)) {
                try {
                    delete(new File(vomsdir + File.separator + voName));
                } catch (IOException e) {
                    JOptionPane.showMessageDialog(null,
                            "Cannot remove dirctory '" + vomsdir + File.separator + voName + "'.",
                            "Error: Remove VO from " + FAVOURITES, JOptionPane.ERROR_MESSAGE);
                }/*from  www. j  a va  2s .  c  o m*/
            }
            allFavVOs.remove(vonameinMap);
            isRemoved = true;
            break;
        }
    }
    if (isRemoved) {
        String newContent = createStringFromTreeMap(allFavVOs);
        try {
            writeToFile(favouritesFile, newContent);
        } catch (IOException e) {
            isRemoved = false;
            JOptionPane.showMessageDialog(null,
                    "Failed to remove VO from Favourites. Cannot write to file '" + favouritesFile + "'",
                    "Error: Remove VO", JOptionPane.ERROR_MESSAGE);
        }
    }

    return isRemoved;
}

From source file:com._17od.upm.gui.DatabaseActions.java

public void errorHandler(Exception e) {
    e.printStackTrace();/*from w ww. j  av a 2  s .co  m*/
    String errorMessage = e.getMessage();
    if (errorMessage == null) {
        errorMessage = e.getClass().getName();
    }
    JOptionPane.showMessageDialog(mainWindow, errorMessage, Translator.translate("error"),
            JOptionPane.ERROR_MESSAGE);
}

From source file:io.heming.accountbook.ui.MainFrame.java

private void importRecords() {
    final JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.addChoosableFileFilter(new AbbFileFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    int value = chooser.showOpenDialog(this);
    if (value == JFileChooser.APPROVE_OPTION) {
        // ?//w  w  w. ja  va2s  . c  o m
        disableAllControls();
        new Thread() {
            @Override
            public void run() {
                try {
                    statusLabel.setIcon(new ImageIcon(getClass().getResource("loader.gif")));
                    setStatusText("?...");
                    FacadeUtil.shutdown();
                    File file = chooser.getSelectedFile();
                    setStatusText("??...");
                    FileUtils.cleanDirectory(new File(Constants.DATA_DIR));
                    setStatusText("??...");
                    ZIPUtil.decompress(file, new File(Constants.HOME_DIR));
                    setStatusText("?...");
                    FacadeUtil.restart();
                    // ??
                    setStatusText("????...");
                    categories = categoryFacade.listBySale();
                    // ????
                    setStatusText("?...");
                    searchRecords();
                    enableAllControls();
                    setStatusText("");
                    statusLabel.setIcon(new ImageIcon(getClass().getResource("stopped-loader.png")));
                    JOptionPane.showMessageDialog(MainFrame.this, "???", "?",
                            JOptionPane.INFORMATION_MESSAGE);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(MainFrame.this, e.getMessage(), "",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }.start();
    }
}

From source file:eremeykin.pete.plotter.PolarPlotterTopComponent.java

@Override
public void update() {
    // for first rpt file
    if (model == null) {
        clear();/*ww w  .  java2  s  .co m*/
        return;
    }
    File[] rptFiles = home.listFiles(filter());
    // catch if there is no such file
    if (rptFiles.length == 0) {
        clear();
        return;
    }
    File firstRPT = rptFiles[0];

    Scanner scanner;
    try {
        scanner = new Scanner(firstRPT);
        scanner.useDelimiter("\\s+|\n");
    } catch (FileNotFoundException ex) {
        clear();
        return;
    }
    List<Map.Entry<Double, Double>> tmpList = new ArrayList<>();
    for (int i = 0; scanner.hasNext(); i++) {
        String line = scanner.next();
        try {
            double x1 = Double.valueOf(line);
            line = scanner.next();
            double x2 = Double.valueOf(line);
            //                System.out.println("x1=" + x1 + "\nx2=" + x2);
            tmpList.add(new AbstractMap.SimpleEntry<>(x1, x2));
        } catch (NumberFormatException ex) {
            // only if it is the third or following line
            if (i > 1) {
                LOGGER.error("Error while parsing double from file: " + firstRPT.getAbsolutePath());
                JOptionPane.showMessageDialog(this, "Error while parsing result file.", "Parsing error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

    }
    if (tmpList.isEmpty()) {
        clear();
        return;
    }
    fillData(tmpList);

    //        fillData(tmpList, dataSeries, toleranceSeries);        
}

From source file:v800_trainer.JCicloTronic.java

/** Creates new form JCicloTronic */
public JCicloTronic() {

    ScreenSize = new Dimension();
    SelectionChanged = false;/*from w  w w.ja v  a2  s. c  o  m*/
    ScreenSize.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50,
            java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50);
    Size = new Dimension();

    Properties = new java.util.Properties();
    SystemProperties = java.lang.System.getProperties();
    chooser = new javax.swing.JFileChooser();
    RawData = new byte[98316];
    //        System.setProperty("jna.library.path" , "C:/WINDOWS/system32");

    try {
        FileInputStream in = new FileInputStream(SystemProperties.getProperty("user.dir")
                + SystemProperties.getProperty("file.separator") + "JCicloexp.cfg");
        Properties.load(in);
        in.close();
    } catch (Exception e) {
        FontSize = 20;
        setFontSizeGlobal("Tahoma", FontSize);

        JOptionPane.showMessageDialog(null,
                "Keine Config-Datei in:  " + SystemProperties.getProperty("user.dir"), "Achtung!",
                JOptionPane.ERROR_MESSAGE);
        Properties.put("working.dir", SystemProperties.getProperty("user.dir"));
        Eigenschaften = new Eigenschaften(new javax.swing.JFrame(), true, this);
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double width = screenSize.getWidth();
        double height = screenSize.getHeight();
        this.setSize(new Dimension((int) width, (int) height));
        this.setPreferredSize(new Dimension((int) width, (int) height));
        this.setMinimumSize(new Dimension((int) width, (int) height));
        repaint();
    }
    try {

        UIManager.setLookAndFeel(Properties.getProperty("LookFeel"));
        SwingUtilities.updateComponentTreeUI(this);
        this.pack();
    } catch (Exception exc) {
    }

    if (debug) {
        try {
            System.setErr(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
            //        System.err =  new FileOutputStream(Properties.getProperty("working.dir") + SystemProperties.getProperty("file.separator") + "error.txt");
            System.setOut(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
        } catch (Exception err) {
        }
    }

    initComponents();

    setTitle("V800 Trainer    Datadir: " + Properties.getProperty("data.dir"));

    icon = new ImageIcon("hw.jpg");
    setIconImage(icon.getImage());

    if (Integer.parseInt(Properties.getProperty("View Geschw", "1")) == 1) {
        Graphik_check_Geschwindigkeit.setSelected(true);
    } else {
        Graphik_check_Geschwindigkeit.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hhe", "1")) == 1) {
        Graphik_check_Hhe.setSelected(true);
    } else {
        Graphik_check_Hhe.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hf", "1")) == 1) {
        Graphik_check_HF.setSelected(true);
    } else {
        Graphik_check_HF.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Temp", "1")) == 1) {
        Graphik_check_Temp.setSelected(true);
    } else {
        Graphik_check_Temp.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigp", "1")) == 1) {
        Graphik_check_Steigung_p.setSelected(true);
    } else {
        Graphik_check_Steigung_p.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigm", "1")) == 1) {
        Graphik_check_Steigung_m.setSelected(true);
    } else {
        Graphik_check_Steigung_m.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View av_Geschw", "1")) == 1) {
        Graphik_check_av_Geschw.setSelected(true);
    } else {
        Graphik_check_av_Geschw.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Cadence", "1")) == 1) {
        Graphik_check_Cadence.setSelected(true);
    } else {
        Graphik_check_Cadence.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Schrittlnge", "1")) == 1) {
        Graphik_check_Schrittlnge.setSelected(true);
    } else {
        Graphik_check_Schrittlnge.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("ZeitStreckeAbstnde", "1")) == 1) {
        Graphik_check_Abstand.setSelected(true);
    } else {
        Graphik_check_Abstand.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("SummenHisto", "1")) == 1) {
        Summenhistogramm_Check.setSelected(true);
    } else {
        Summenhistogramm_Check.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("xy_Strecke", "1")) == 1) {
        Graphik_Radio_Strecke.setSelected(true);
        Graphik_Radio_Zeit.setSelected(false);
    } else {
        Graphik_Radio_Strecke.setSelected(false);
        Graphik_Radio_Zeit.setSelected(true);
    }

    //Buttons fr XY-Darstellung   (ber Strecke oder ber Zeit)
    X_Axis = new ButtonGroup();
    X_Axis.add(Graphik_Radio_Strecke);
    X_Axis.add(Graphik_Radio_Zeit);

    //Buttons fr Jahresbersicht
    bersicht = new ButtonGroup();
    bersicht.add(jRadioButton_jahresverlauf);
    bersicht.add(jRadioButton_monatsbersicht);

    Datenliste_Zeitabschnitt.addItem("nicht aktiv");
    Datenliste_Zeitabschnitt.addItem("vergangene Woche");
    Datenliste_Zeitabschnitt.addItem("vergangener Monat");
    Datenliste_Zeitabschnitt.addItem("vergangenes Jahr");
    Datenliste_Zeitabschnitt.addItem("Alles");

    if (Datentabelle.getRowCount() != 0) {
        Datentabelle.addRowSelectionInterval(0, 0);
        Datenliste_scroll_Panel.getViewport().setViewPosition(new java.awt.Point(0, 0));
    }
    //        if (Properties.getProperty("CommPort").equals("nocom")) {
    //            jMenuReceive.setEnabled(false);
    //        } else {
    //            jMenuReceive.setEnabled(true);
    //        }

    jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount());

    setFileChooserFont(chooser.getComponents());
    locmap = true;
    Map_Type.removeAllItems();
    Map_Type.addItem("OpenStreetMap");
    Map_Type.addItem("Virtual Earth Map");
    Map_Type.addItem("Virtual Earth Satelite");
    Map_Type.addItem("Virtual Earth Hybrid");
    locmap = false;
    //    ChangeModel();
}

From source file:QueryConnector.java

/** Gestione finestre di dialog **/

private static void error(String msg) {
    JOptionPane.showMessageDialog(null, msg, tr("ERROR_DIALOG_TITLE"), JOptionPane.ERROR_MESSAGE);
}

From source file:com.alvermont.terraj.planet.ui.TerrainFrame.java

private void saveImageItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveImageItemActionPerformed
{//GEN-HEADEREND:event_saveImageItemActionPerformed

    int choice = pngChooser.showSaveDialog(this);

    if (choice == JFileChooser.APPROVE_OPTION) {
        try {// w ww  . j av a 2 s.  c o m
            if (!pngChooser.getFileContents().canRead() || (JOptionPane.showConfirmDialog(this,
                    "This file already exists. Do you want to\n" + "overwrite it?", "Replace File?",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
                final OutputStream target = pngChooser.getFileContents().getOutputStream(true);

                // More JNLP silliness. How am I supposed to know what size
                // an image file will compress to and there is no guidance
                // in the documentation as to what value can be reasonably
                // requested here. I've just picked something and gone with
                // it, which seems to be in line with the philosophy of
                // the people who designed Java WebStart
                pngChooser.getFileContents().setMaxLength(500000);

                ImageIO.write(image,
                        PNGFileFilter.getFormatName(new File(pngChooser.getFileContents().getName())), target);

                target.close();
            }
        } catch (IOException ioe) {
            log.error("Error writing image file", ioe);

            JOptionPane.showMessageDialog(this,
                    "Error: " + ioe.getMessage() + "\nCheck log file for full details", "Error Saving",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}