Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

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

Prototype

int INFORMATION_MESSAGE

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

Click Source Link

Document

Used for information messages.

Usage

From source file:com.googlecode.logVisualizer.chart.StatDevelopmentChartMouseEventListener.java

public void chartMouseClicked(final ChartMouseEvent e) {
    if (e.getEntity() instanceof XYItemEntity) {
        final XYItemEntity entity = (XYItemEntity) e.getEntity();
        final int turnNumber = entity.getDataset().getX(0, entity.getItem()).intValue();

        Turn turn = null;//ww w.j av  a 2s  .c om
        if (logData.isDetailedLog())
            for (final SingleTurn st : logData.getTurnsSpent()) {
                if (st.getTurnNumber() == turnNumber) {
                    turn = st;
                    break;
                }
            }
        else
            for (final TurnInterval ti : logData.getTurnIntervalsSpent())
                if (ti.getEndTurn() == turnNumber) {
                    turn = ti;
                    break;
                }

        EquipmentChange equipment = null;
        if (logData.isDetailedLog())
            equipment = ((SingleTurn) turn).getUsedEquipment();
        final StringBuilder str = new StringBuilder(250);
        str.append("Turn spent in area: " + turn.getAreaName() + "\n");
        if (logData.isDetailedLog())
            str.append("Encounter name: " + ((SingleTurn) turn).getEncounterName() + "\n");
        str.append("Stats gained: " + turn.getStatGain() + "\n");
        if (logData.isDetailedLog()) {
            str.append("Familiar used: " + ((SingleTurn) turn).getUsedFamiliar().getFamiliarName() + "\n\n");
            str.append("Equipment:\n");
            str.append("    Hat: " + equipment.getHat() + "\n");
            str.append("    Weapon: " + equipment.getWeapon() + "\n");
            str.append("    Offhand: " + equipment.getOffhand() + "\n");
            str.append("    Shirt: " + equipment.getShirt() + "\n");
            str.append("    Pants: " + equipment.getPants() + "\n");
            str.append("    Acc1: " + equipment.getAcc1() + "\n");
            str.append("    Acc2: " + equipment.getAcc2() + "\n");
            str.append("    Acc3: " + equipment.getAcc3() + "\n");
            str.append("    FamEquip: " + equipment.getFamEquip() + "\n");
        }
        str.append("\nConsumables used:\n");
        for (final Consumable c : turn.getConsumablesUsed())
            str.append("    " + c + "\n");
        str.append("\nItems dropped:\n");
        for (final Item i : turn.getDroppedItems())
            str.append("    " + i + "\n");

        final JScrollPane text = new JScrollPane(new JTextArea(str.toString()));
        text.setPreferredSize(new Dimension(500, 450));
        JOptionPane.showMessageDialog(null, text, "Information on " + turn, JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:hr.fer.zemris.vhdllab.applets.texteditor.TextEditor.java

@Override
protected JComponent doInitWithoutData() {
    textPane = new CustomJTextPane(this);
    wrapInScrollPane = false;/*from  www . ja va2  s  .  com*/

    JScrollPane jsp = new JScrollPane(textPane);
    LineNumbers.createInstance(textPane, jsp, 30);

    Document document = textPane.getDocument();

    if (document instanceof AbstractDocument) {
        ((AbstractDocument) document).setDocumentFilter(new DocumentFilter() {

            @Override
            public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs)
                    throws BadLocationException {
                if (text != null && (text.length() - length) > 10
                        && !text.equals(CustomJTextPane.getClipboardText()) && !textIsBlank(text)) {
                    informPastingIsDisabled();
                } else {
                    super.replace(fb, offset, length, text, attrs);
                }
            }

            private boolean textIsBlank(String text) {
                if (text == null)
                    return true;
                for (char c : text.toCharArray()) {
                    switch (c) {
                    case ' ':
                        break;
                    case '\t':
                        break;
                    case '\r':
                        break;
                    case '\n':
                        break;
                    default:
                        return false;
                    }
                }
                return true;
            }

            private void informPastingIsDisabled() {
                JFrame frame = Application.instance().getActiveWindow().getControl();
                JOptionPane.showMessageDialog(frame, "Pasting text from outside of vhdllab is disabled!",
                        "Paste text", JOptionPane.INFORMATION_MESSAGE);
            }

        });
    }

    textPane.addCaretListener(this);
    // commitTrigger = new CommitTrigger();
    // TextComponentPopup.attachPopup(textPane, commitTrigger);

    return jsp;
}

From source file:net.sf.jabref.importer.fetcher.DOAJFetcher.java

@Override
public boolean processQuery(String query, ImportInspector inspector, OutputPrinter status) {
    shouldContinue = true;/*from  w ww  . j  av  a 2 s. c o  m*/
    try {
        status.setStatus(Localization.lang("Searching..."));
        HttpResponse<JsonNode> jsonResponse;
        jsonResponse = Unirest.get(SEARCH_URL + query + "?pageSize=1").header("accept", "application/json")
                .asJson();
        JSONObject jo = jsonResponse.getBody().getObject();
        int hits = jo.getInt("total");
        int numberToFetch = 0;
        if (hits > 0) {
            if (hits > MAX_PER_PAGE) {
                while (true) {
                    String strCount = JOptionPane.showInputDialog(
                            Localization.lang("References found") + ": " + hits + "  "
                                    + Localization.lang("Number of references to fetch?"),
                            Integer.toString(hits));

                    if (strCount == null) {
                        status.setStatus(Localization.lang("%0 import canceled", "DOAJ"));
                        return false;
                    }

                    try {
                        numberToFetch = Integer.parseInt(strCount.trim());
                        break;
                    } catch (NumberFormatException ex) {
                        status.showMessage(Localization.lang("Please enter a valid number"));
                    }
                }
            } else {
                numberToFetch = hits;
            }

            int fetched = 0; // Keep track of number of items fetched for the progress bar
            for (int page = 1; ((page - 1) * MAX_PER_PAGE) <= numberToFetch; page++) {
                if (!shouldContinue) {
                    break;
                }

                int noToFetch = Math.min(MAX_PER_PAGE, numberToFetch - ((page - 1) * MAX_PER_PAGE));
                jsonResponse = Unirest.get(SEARCH_URL + query + "?page=" + page + "&pageSize=" + noToFetch)
                        .header("accept", "application/json").asJson();
                jo = jsonResponse.getBody().getObject();
                if (jo.has("results")) {
                    JSONArray results = jo.getJSONArray("results");
                    for (int i = 0; i < results.length(); i++) {
                        JSONObject bibJsonEntry = results.getJSONObject(i).getJSONObject("bibjson");
                        BibEntry entry = jsonConverter.parseBibJSONtoBibtex(bibJsonEntry);
                        inspector.addEntry(entry);
                        fetched++;
                        inspector.setProgress(fetched, numberToFetch);
                    }
                }
            }
            return true;
        } else {
            status.showMessage(Localization.lang("No entries found for the search string '%0'", query),
                    Localization.lang("Search %0", "DOAJ"), JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
    } catch (UnirestException e) {
        LOGGER.warn("Problem searching DOAJ", e);
        status.setStatus(Localization.lang("%0 import canceled", "DOAJ"));
        return false;
    }

}

From source file:edu.harvard.i2b2.patientMapping.serviceClient.IMQueryClient.java

public static String sendSetKeyQueryRequestREST(String XMLstr) {
    try {/*from  w  ww  .  ja  v a  2  s.c o  m*/
        SAXBuilder parser = new SAXBuilder();
        String xmlContent = XMLstr;
        java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
        org.jdom.Document tableDoc = parser.build(xmlStringReader);
        XMLOutputter o = new XMLOutputter();
        o.setFormat(Format.getPrettyFormat());
        StringWriter str = new StringWriter();
        o.output(tableDoc, str);

        MessageUtil.getInstance().setRequest("URL: " + getSetKeyServiceName() + "\n" + str);//XMLstr);

        OMElement payload = getQueryPayLoad(XMLstr);
        Options options = new Options();

        targetEPR = new EndpointReference(getSetKeyServiceName());
        options.setTo(targetEPR);

        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
        options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(600000));
        options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(600000));

        ServiceClient sender = new ServiceClient();
        sender.setOptions(options);

        OMElement responseElement = sender.sendReceive(payload);
        MessageUtil.getInstance()
                .setResponse("URL: " + getSetKeyServiceName() + "\n" + responseElement.toString());

        return responseElement.toString();
    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null,
                        "Trouble with connection to the remote server, "
                                + "this is often a network error, please try again",
                        "Network Error", JOptionPane.INFORMATION_MESSAGE);
            }
        });

        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:control.JGeraGraficos.java

public void PrintGraficoSegundoExemplo() {
    String valorJava = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJAVA.txt");
    String valorJavaThRead = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJAVATHREAD.txt");
    String valorJOCL = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJOCL.txt");
    if (valorJava.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo Java No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else if (valorJavaThRead.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo Java ThRead No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else if (valorJOCL.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo JOCL No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else {//  w w  w.j  av a 2s.  c  o m
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.clear();
        dataset.addValue(Float.parseFloat(valorJava), "Java", "Java");
        dataset.addValue(Float.parseFloat(valorJavaThRead), "Java ThRead", "Java ThRead");
        dataset.addValue(Float.parseFloat(valorJOCL), "JOCL", "JOCL");
        JFreeChart chart = ChartFactory.createBarChart("Grafio de Performance", null, "Tempo(ms)", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        ChartFrame frame = new ChartFrame("Grafio de Performance", chart);

        frame.setBounds(300, 78, 800, 620);
        frame.setVisible(true);
    }
}

From source file:net.sf.keystore_explorer.gui.actions.ExportTrustedCertificateAction.java

/**
 * Do action./*  ww  w .ja  v a2 s.  co m*/
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        DExportCertificates dExportCertificates = null;
        X509Certificate cert = null;
        if (certFromConstructor == null) {
            String alias = kseFrame.getSelectedEntryAlias();
            dExportCertificates = new DExportCertificates(frame, alias, false);
            cert = getCertificate(alias);
        } else {
            cert = certFromConstructor;
            dExportCertificates = new DExportCertificates(frame, X509CertUtil.getCertificateAlias(cert), false);
        }

        dExportCertificates.setLocationRelativeTo(frame);
        dExportCertificates.setVisible(true);

        if (!dExportCertificates.exportSelected()) {
            return;
        }

        exportFile = dExportCertificates.getExportFile();

        boolean pemEncode = dExportCertificates.pemEncode();

        byte[] encoded = null;

        if (dExportCertificates.exportFormatX509()) {
            if (pemEncode) {
                encoded = X509CertUtil.getCertEncodedX509Pem(cert).getBytes();
            } else {
                encoded = X509CertUtil.getCertEncodedX509(cert);
            }
        } else if (dExportCertificates.exportFormatPkcs7()) {
            if (pemEncode) {
                encoded = X509CertUtil.getCertEncodedPkcs7Pem(cert).getBytes();
            } else {
                encoded = X509CertUtil.getCertEncodedPkcs7(cert);
            }
        } else if (dExportCertificates.exportFormatPkiPath()) {
            encoded = X509CertUtil.getCertEncodedPkiPath(cert);
        } else if (dExportCertificates.exportFormatSpc()) {
            encoded = X509CertUtil.getCertEncodedPkcs7(cert); // SPC is just DER PKCS #7
        }

        exportEncodedCertificate(encoded, exportFile);

        JOptionPane.showMessageDialog(frame,
                res.getString("ExportTrustedCertificateAction.ExportCertificateSuccessful.message"),
                res.getString("ExportTrustedCertificateAction.ExportCertificate.Title"),
                JOptionPane.INFORMATION_MESSAGE);
    } catch (FileNotFoundException ex) {
        String message = MessageFormat
                .format(res.getString("ExportTrustedCertificateAction.NoWriteFile.message"), exportFile);

        JOptionPane.showMessageDialog(frame, message,
                res.getString("ExportTrustedCertificateAction.ExportCertificate.Title"),
                JOptionPane.WARNING_MESSAGE);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}

From source file:org.apache.shiro.samples.spring.ui.WebStartView.java

public void actionPerformed(ActionEvent e) {
    try {//from   w  w w  . j a va2 s  .c  o  m

        if (e.getSource() == saveButton) {
            sampleManager.setValue(valueField.getText());

        } else if (e.getSource() == refreshButton) {
            updateValueLabel();

        } else if (e.getSource() == secureMethod1Button) {
            sampleManager.secureMethod1();
            JOptionPane.showMessageDialog(frame, "Method #1 successfully called.", "Success",
                    JOptionPane.INFORMATION_MESSAGE);

        } else if (e.getSource() == secureMethod2Button) {
            sampleManager.secureMethod2();
            JOptionPane.showMessageDialog(frame, "Method #2 successfully called.", "Success",
                    JOptionPane.INFORMATION_MESSAGE);
        } else if (e.getSource() == secureMethod3Button) {
            sampleManager.secureMethod3();
            JOptionPane.showMessageDialog(frame, "Method #3 successfully called.", "Success",
                    JOptionPane.INFORMATION_MESSAGE);

        } else {
            throw new RuntimeException("Unexpected action event from source: " + e.getSource());
        }

    } catch (AuthorizationException ae) {
        JOptionPane.showMessageDialog(frame, "Unauthorized to perform action: " + ae.getMessage(),
                "Unauthorized", JOptionPane.WARNING_MESSAGE);
    }
}

From source file:net.sf.jabref.sql.importer.DbImportAction.java

private void performImport() {
    if (!connectedToDB) {
        return;/*from  w ww.j a  va2  s.c o m*/
    }

    frame.output(Localization.lang("Attempting SQL import..."));
    DBExporterAndImporterFactory factory = new DBExporterAndImporterFactory();
    DatabaseImporter importer = factory.getImporter(dbs.getDbPreferences().getServerType());
    try {
        try (Connection conn = importer.connectToDB(dbs);
                Statement statement = conn.createStatement();
                ResultSet rs = statement.executeQuery(SQLUtil.queryAllFromTable("jabref_database"))) {

            Vector<Vector<String>> matrix = new Vector<>();

            while (rs.next()) {
                Vector<String> v = new Vector<>();
                v.add(rs.getString("database_name"));
                matrix.add(v);
            }

            if (matrix.isEmpty()) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang("There are no available databases to be imported"),
                        Localization.lang("Import from SQL database"), JOptionPane.INFORMATION_MESSAGE);
            } else {
                DBImportExportDialog dialogo = new DBImportExportDialog(frame, matrix,
                        DBImportExportDialog.DialogType.IMPORTER);
                if (dialogo.removeAction) {
                    String dbName = dialogo.selectedDB;
                    DatabaseUtil.removeDB(dialogo, dbName, conn, databaseContext);
                    performImport();
                } else if (dialogo.moreThanOne) {
                    // use default DB mode for import
                    databases = importer.performImport(dbs, dialogo.listOfDBs,
                            Globals.prefs.getDefaultBibDatabaseMode());
                    for (DBImporterResult res : databases) {
                        databaseContext = res.getDatabaseContext();
                        dbs.isConfigValid(true);
                    }
                    frame.output(Localization.lang("%0 databases will be imported",
                            Integer.toString(databases.size())));
                } else {
                    frame.output(Localization.lang("Importing canceled"));
                }
            }
        }
    } catch (Exception ex) {
        String preamble = Localization.lang("Could not import from SQL database for the following reason:");
        String errorMessage = SQLUtil.getExceptionMessage(ex);
        dbs.isConfigValid(false);
        JOptionPane.showMessageDialog(frame, preamble + '\n' + errorMessage,
                Localization.lang("Import from SQL database"), JOptionPane.ERROR_MESSAGE);
        frame.output(Localization.lang("Error importing from database"));
        LOGGER.error("Error importing from database", ex);
    }
}

From source file:net.sf.jabref.importer.fetcher.SpringerFetcher.java

@Override
public boolean processQuery(String query, ImportInspector inspector, OutputPrinter status) {
    shouldContinue = true;/* w w w . j  a  v  a  2s  . c om*/
    try {
        status.setStatus(Localization.lang("Searching..."));
        HttpResponse<JsonNode> jsonResponse;
        String encodedQuery = URLEncoder.encode(query, "UTF-8");
        jsonResponse = Unirest.get(API_URL + encodedQuery + "&api_key=" + API_KEY + "&p=1")
                .header("accept", "application/json").asJson();
        JSONObject jo = jsonResponse.getBody().getObject();
        int hits = jo.getJSONArray("result").getJSONObject(0).getInt("total");
        int numberToFetch = 0;
        if (hits > 0) {
            if (hits > MAX_PER_PAGE) {
                while (true) {
                    String strCount = JOptionPane.showInputDialog(
                            Localization.lang("References found") + ": " + hits + "  "
                                    + Localization.lang("Number of references to fetch?"),
                            Integer.toString(hits));

                    if (strCount == null) {
                        status.setStatus(Localization.lang("%0 import canceled", getTitle()));
                        return false;
                    }

                    try {
                        numberToFetch = Integer.parseInt(strCount.trim());
                        break;
                    } catch (NumberFormatException ex) {
                        status.showMessage(Localization.lang("Please enter a valid number"));
                    }
                }
            } else {
                numberToFetch = hits;
            }

            int fetched = 0; // Keep track of number of items fetched for the progress bar
            for (int startItem = 1; startItem <= numberToFetch; startItem += MAX_PER_PAGE) {
                if (!shouldContinue) {
                    break;
                }

                int noToFetch = Math.min(MAX_PER_PAGE, (numberToFetch - startItem) + 1);
                jsonResponse = Unirest.get(
                        API_URL + encodedQuery + "&api_key=" + API_KEY + "&p=" + noToFetch + "&s=" + startItem)
                        .header("accept", "application/json").asJson();
                jo = jsonResponse.getBody().getObject();
                if (jo.has("records")) {
                    JSONArray results = jo.getJSONArray("records");
                    for (int i = 0; i < results.length(); i++) {
                        JSONObject springerJsonEntry = results.getJSONObject(i);
                        BibEntry entry = JSONEntryParser.parseSpringerJSONtoBibtex(springerJsonEntry);
                        inspector.addEntry(entry);
                        fetched++;
                        inspector.setProgress(fetched, numberToFetch);
                    }
                }
            }
            return true;
        } else {
            status.showMessage(Localization.lang("No entries found for the search string '%0'", encodedQuery),
                    Localization.lang("Search %0", getTitle()), JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
    } catch (UnirestException e) {
        LOGGER.warn("Problem searching Springer", e);
    } catch (UnsupportedEncodingException e) {
        LOGGER.warn("Cannot encode query", e);
    }
    return false;

}

From source file:net.openbyte.gui.WelcomeFrame.java

private void button5ActionPerformed(ActionEvent e) {
    String selectedText = (String) list1.getSelectedValue();
    listItems.remove(list1.getSelectedIndex());
    OpenProjectSolution solution = Launch.nameToSolution.get(selectedText);
    System.gc();/*from   w w w  . j a  v  a 2s.com*/
    try {
        FileUtils.deleteDirectory(solution.getProjectFolder());
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    list1.clearSelection();
    solution.deleteSolution();
    JOptionPane.showMessageDialog(this, "Deleted the project successfully!", "Success",
            JOptionPane.INFORMATION_MESSAGE);
}