Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

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

Prototype

public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Brings up an information-message dialog titled "Message".

Usage

From source file:org.earthtime.archivingTools.IEDACredentialsValidator.java

public static String validateSesarCredentials(String username, String password, boolean isVerbose) {

    String sesarCredentialsService = "http://app.geosamples.org/webservices/credentials_service.php";//note test http://sesar3.geoinfogeochem.org/webservices/credentials_service.php
    boolean valid = false;
    // Feb 2015 userCode is prefix for IGSN
    String userCode = "";

    // using geochron as identifier since both are same and need backward compartibility for serialization
    ReduxPersistentState myState = ReduxPersistentState.getExistingPersistentState();
    myState.getReduxPreferences().setGeochronUserName(username);
    myState.getReduxPreferences().setGeochronPassWord(password);
    myState.serializeSelf();//from  www.  ja  va2s.c om

    Document doc = HTTP_PostAndResponse(username, password, sesarCredentialsService);

    if (doc != null) {
        if (doc.getElementsByTagName("valid").getLength() > 0) {
            valid = doc.getElementsByTagName("valid").item(0).getTextContent().trim().equalsIgnoreCase("yes");
            if (valid) {
                userCode = doc.getElementsByTagName("user_code").item(0).getTextContent().trim();
            }
        }

        if (isVerbose) {
            JOptionPane.showMessageDialog(null, new String[] {
                    valid ? "SESAR credentials are VALID!\n" : "SESAR credentials NOT valid!\n" });
        }
    } else {
        if (isVerbose) {
            JOptionPane.showMessageDialog(null, new String[] {
                    "SESAR Credentials Server " + sesarCredentialsService + " cannot be located.\n" });
        }
    }
    return userCode;
}

From source file:framework.classes.PoolConexion.java

/**
 * CLOSE CONNECTION/*  w w  w  .j a  v  a2 s. c  o  m*/
 * @param conexion 
 */
public static void LiberarConexion(Connection conexion) {
    try {
        if (null != conexion)
            // En realidad no cierra, solo libera la conexion.
            conexion.close();
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:actions.ScanFileAction.java

@Override
public void actionPerformed(ActionEvent e) {
    new SwingWorker() {
        @Override/*from  w w  w  .  j  av  a  2  s  .c o  m*/
        protected Object doInBackground() throws Exception {
            if (pmFileNode.pmFile.isIsScanned()) {
                JOptionPane.showMessageDialog(null, "The file has been already scanned.");
            }
            if (VirusTotalAPIHelper.apiKey.equals("")) {
                VirusTotalAPIHelper.apiKey = JOptionPane.showInputDialog("Enter valid API key");
            }
            if (VirusTotalAPIHelper.apiKey.equals("")) {
                return null;
            } else {
                // scan file and get the report.
                CloseableHttpResponse scanFileResponse = VirusTotalAPIHelper
                        .scanFile(pmFileNode.pmFile.getFile());
                try {
                    JSONObject obj = (JSONObject) parser
                            .parse(getStringFromClosableHttpResponse(scanFileResponse));
                    pmFileNode.pmFile.isScanned = true;
                    pmFileNode.pmFile.md5 = (String) obj.get("md5");
                    pmFileNode.pmFile.sha1 = (String) obj.get("sha1");
                    pmFileNode.pmFile.sha2 = (String) obj.get("sha256");
                    pmFileNode.pmFile.scan_id = (String) obj.get("scan_id");
                } catch (ParseException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
            CloseableHttpResponse reportResponse = VirusTotalAPIHelper.getReport(pmFileNode.pmFile.getSha2());
            try {
                JSONObject obj = (JSONObject) parser.parse(getStringFromClosableHttpResponse(reportResponse));
                pmFileNode.pmFile.scanDate = (String) obj.get("scan_date");
                pmFileNode.pmFile.positives = (Long) obj.get("positives");
                pmFileNode.pmFile.totals = (Long) obj.get("total");
                JSONObject scans = (JSONObject) obj.get("scans");
                if (scans != null && !scans.isEmpty()) {
                    Iterator iterator = scans.entrySet().iterator();
                    while (iterator.hasNext()) {
                        Map.Entry pair = (Map.Entry) iterator.next();
                        JSONObject scan = (JSONObject) pair.getValue();
                        pmFileNode.pmFile.listOfScans.add(new Scan((String) pair.getKey(), true,
                                scan.get("result") == null ? "" : (String) scan.get("result"),
                                scan.get("version") == null ? "" : (String) scan.get("version"),
                                scan.get("update") == null ? "" : (String) scan.get("update")));
                        iterator.remove(); // avoids a ConcurrentModificationException
                        pmFileNode.pmFile.numberOfScans++;
                    }
                }

            } catch (ParseException ex) {
                Exceptions.printStackTrace(ex);
            }
            MainWindowTopComponent.getInstance().writeOutput(pmFileNode.pmFile.toString());
            pmFileNode.pmfcf.refresh(pmFileNode.pmFile);
            return null;
        }
    }.run();

}

From source file:framework.classes.connectionDB.java

public static void init_BasicDataSourceFactory() {
    Properties propiedades = new Properties();
    /*/*from w w w. ja  va  2 s .  c o m*/
    setMaxActive(): N mx de conexiones que se pueden abrir simultneamente.
    setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms.
    setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando.
    */
    propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver");
    propiedades.setProperty("url", "jdbc:mysql://localhost:3306/app");
    propiedades.setProperty("maxActive", "10");
    propiedades.setProperty("maxIdle", "8");
    propiedades.setProperty("minIdle", "0");
    propiedades.setProperty("maxWait", "500");
    propiedades.setProperty("initialSize", "5");
    propiedades.setProperty("defaultAutoCommit", "true");
    propiedades.setProperty("username", "root");
    propiedades.setProperty("password", "root");
    propiedades.setProperty("validationQuery", "select 1");
    propiedades.setProperty("validationQueryTimeout", "100");
    propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2");
    propiedades.setProperty("poolPreparedStatements", "true");
    propiedades.setProperty("maxOpenPreparedStatements", "10");

    try {

        dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:com.vrane.metaGlacier.gui.SNSTopicDialog.java

SNSTopicDialog() {
    super(Main.frame, true);
    JPanel mainPanel = new JPanel(new GridLayout(4, 2));
    final JTextField topicNameJT = new JTextField(10);
    final JTextField emailJT = new JTextField(10);
    final JButton subscribeButton = new JButton("subscribe");

    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));

    mainPanel.add(new JLabel("topic name"));
    mainPanel.add(topicNameJT);/*ww  w.  jav a 2s.  c o  m*/

    mainPanel.add(new JLabel("email"));
    mainPanel.add(emailJT);

    final String metadata_account_email = Main.frame.getMPCUser();
    if (metadata_account_email != null) {
        emailJT.setText(metadata_account_email);
    }

    mainPanel.add(new JLabel());
    mainPanel.add(subscribeButton);
    subscribeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            final String email = emailJT.getText();
            final String name = topicNameJT.getText();
            boolean success = false;

            if (!EmailValidator.getInstance().isValid(email)) {
                JOptionPane.showMessageDialog(null, "Invalid email address");
                return;
            }
            try {
                success = new SNSTopic().createTopic(name, email);
            } catch (Exception ex) {
                LGR.log(Level.SEVERE, null, ex);
            }
            if (success) {
                JOptionPane.showMessageDialog(null, "Please check your email to confirm");
                dispose();
                return;
            }
            JOptionPane.showMessageDialog(null, "Error subscribing");
        }
    });
    add(mainPanel);
    pack();
    setLocationRelativeTo(Main.frame);
    setVisible(true);
}

From source file:control.LoadControler.java

public static Map<String, Integer> loadmainSettings(String filePath) {

    Map<String, Integer> list = new HashMap<>();

    File file = new File(userPath(filePath));

    try {/*w w  w  .  ja  v  a  2s .  c  o m*/
        PropertiesReader ppr = new PropertiesReader(file.getCanonicalPath());
        Properties properties = ppr.readProperties();

        try {
            Integer nbInitSoldatsParHeros = Integer.parseInt(properties.getProperty("nbInitSoldatsParHeros"));
            Integer xpInit = Integer.parseInt(properties.getProperty("xpInit"));
            Integer popNiveau10 = Integer.parseInt(properties.getProperty("popNiveau10"));

            list.put("nbInitSoldatsParHeros", nbInitSoldatsParHeros);
            list.put("xpInit", xpInit);
            list.put("popNiveau10", popNiveau10);

            System.out.println(list.toString()); //DEBUG

        } catch (NumberFormatException e) {
            e.printStackTrace();
            System.out.println("##### Erreur lors de la lecture des paramtres gnraux #####");
            JOptionPane.showMessageDialog(null, e);
        }

    } catch (IOException ex) {
        Logger.getLogger(LoadControler.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex);
    }

    return list;
}

From source file:MstrJadwal.Entry.java

private void Search() {
    try {/*www  . j  av a  2 s  .  c o  m*/
        MstrJadwal x = new MstrJadwal();
        x.Search(_ID);
        if (x._Akses.equals("-")) {
            txt_id.setText(x.id_jadwal);
            txt_mapel.setText(x.nama_mata);
            txt_jam.setText(x.jam_belajar);
            cmb_hari.setSelectedItem(x.hari);
            txt_tempat.setText(x.tempat);
            cmb_nama_pengajar.setSelectedItem(x.nama_pengajar);
            txt_id.setEditable(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

From source file:model.WebServiceRequest.java

public String getResponse(String pais, String ciudad) {
    pais = pais.replace(" ", "%20");
    ciudad = ciudad.replace(" ", "%20");
    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        HttpGet httpGet = new HttpGet("http://www.webservicex.net/globalweather.asmx/GetWeather?CityName="
                + ciudad + "&CountryName=" + pais);
        CloseableHttpResponse httpResponse = httpClient.execute(httpGet);

        System.out.println("GET Response Status: " + httpResponse.getStatusLine().getStatusCode());

        StringBuilder response;/*from  w w  w .ja  va 2s.c om*/
        try (BufferedReader reader = new BufferedReader(
                new InputStreamReader(httpResponse.getEntity().getContent()))) {
            String inputLine;
            response = new StringBuilder();
            while ((inputLine = reader.readLine()) != null) {
                response.append(inputLine);
            }
        }
        if (httpResponse.getStatusLine().getStatusCode() == 200) {
            return response.toString();
        } else {
            return "Error.";
        }

    } catch (IOException ex) {
        Logger.getLogger(WebServiceRequest.class.getName()).log(Level.SEVERE, null, ex);
    }
    JOptionPane.showMessageDialog(null, "Se ha presentado un error al acceder al servicio web.");
    return null;
}

From source file:net.itransformers.topologyviewer.menu.handlers.graphFileMenuHandlers.SaveCurrentGraphMenuHandler.java

@Override
public void actionPerformed(ActionEvent e) {
    File path = frame.getPath();//from   www. j a v  a  2 s.com

    if (path == null) {
        JOptionPane.showMessageDialog(frame, "Can not open graph before project has been opened.");
        return;
    }

    JTextField fileName = new JTextField();
    Object[] message = { "File name", fileName };
    String versionName = JOptionPane.showInputDialog("Enter output graph version");

    File networkPath = new File(path + File.separator + ProjectConstants.networkDirName);

    File versionPath = new File(networkPath, versionName);
    if (versionPath.exists()) {
        JOptionPane.showMessageDialog(frame, "Version already exists" + versionPath.getAbsolutePath());

        return;
    }

    if (!versionPath.mkdir()) {
        JOptionPane.showMessageDialog(frame, "Unable to create version path: " + versionPath.getAbsolutePath());
    }

    if ("undirected".equalsIgnoreCase(frame.getCurrentGraphViewerManager().getGraphType().toString())) {
        graphmlDir = new File(versionPath.getAbsolutePath(), ProjectConstants.undirectedGraphmlDirName);

    } else {
        graphmlDir = new File(versionPath.getAbsolutePath(), ProjectConstants.directedGraphmlDirName);

    }
    if (!graphmlDir.mkdir()) {
        JOptionPane.showMessageDialog(frame, "Unable to create version path:" + versionPath.getAbsolutePath(),
                "Error", JOptionPane.WARNING_MESSAGE);
        return;
    }

    Writer fileWriter;
    try {
        fileWriter = new FileWriter(new File(graphmlDir, ProjectConstants.networkGraphmlFileName));
    } catch (IOException e1) {
        JOptionPane.showMessageDialog(frame, "Unable to create network.graphml file:", "Error",
                JOptionPane.WARNING_MESSAGE);
        return;
    }
    GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
    final Graph<String, String> currentGraph = viewerPanel.getCurrentGraph();
    MyGraphMLWriter writer = new MyGraphMLWriter();
    writer.setGraphData(viewerPanel.getGraphmlLoader().getGraphMetadatas());
    writer.setVertexData(viewerPanel.getGraphmlLoader().getVertexMetadatas());
    writer.setEdgeData(viewerPanel.getGraphmlLoader().getEdgeMetadatas());
    writer.setEdgeIDs(new Transformer<String, String>() {

        @Override
        public String transform(String s) {
            Pair<String> endpoints = currentGraph.getEndpoints(s);
            String[] endpointsArr = new String[] { endpoints.getFirst(), endpoints.getSecond() };
            Arrays.sort(endpointsArr);
            return endpointsArr[0] + "_" + endpointsArr[1];
        }
    });
    boolean flag;
    try {
        writer.save(currentGraph, fileWriter);
        flag = true;

    } catch (IOException e1) {
        flag = false;
        JOptionPane.showMessageDialog(frame, "Unable to write graph file:" + e1.getMessage(), "Error",
                JOptionPane.WARNING_MESSAGE);

    }

}

From source file:bankingclient.DKFrame.java

public DKFrame(MainFrame vmain) {
    initComponents();// ww  w .j a va2 s  .c o m
    this.main = vmain;
    this.jTextField1.setText("");
    this.jTextField2.setText("");
    this.jTextField3.setText("");
    this.jTextField4.setText("");
    this.jTextField5.setText("");
    this.setVisible(false);
    jButton1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jTextField2.getText().equals(jTextField3.getText())
                    && NumberUtils.isNumber(jTextField4.getText())
                    && NumberUtils.isNumber(jTextField5.getText())) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    String cusName = jTextField1.getText();
                    String pass = jTextField2.getText();
                    String sdt = jTextField4.getText();
                    String cmt = jTextField5.getText();
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(1);
                    dout.writeUTF(cusName + "\n" + pass + "\n" + sdt + "\n" + cmt);
                    dout.flush();
                    DataInputStream din = new DataInputStream(client.getInputStream());
                    byte check = din.readByte();
                    if (check == 1) {
                        JOptionPane.showMessageDialog(rootPane, "da dang ki tai khoan thanh cong");
                    } else {
                        JOptionPane.showMessageDialog(rootPane, "dang ki tai khoan khong thanh cong");

                    }
                    client.close();
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
                main.setVisible(true);
                DKFrame.this.setVisible(false);

            } else {
                JOptionPane.showMessageDialog(rootPane, "Nhap thong tin sai, moi nhap lai");
            }
        }
    });
    jButton2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            main.setVisible(true);
            DKFrame.this.setVisible(false);
        }
    });
}