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:UserInfo_Frame.java

private void update_table() {
    String sql = "select * from UserInfo";
    try {/*from  w ww  . ja  v  a 2 s . c om*/
        pst = conn.prepareStatement(sql);
        rs = pst.executeQuery();
        Table_UserInfo.setModel(DbUtils.resultSetToTableModel(rs));
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    } finally {
        try {
            rs.close();
            pst.close();
            //conn.close();
        } catch (Exception e) {

        }
    }
}

From source file:bankingclient.DNFrame.java

public DNFrame(MainFrame vmain) {

    initComponents();/*from  w  w  w .  j a  va  2s  . c om*/

    this.jTextField1.setText("");
    this.jTextField2.setText("");
    this.jTextField_cmt.setText("");
    this.jTextField_sdt.setText("");

    this.main = vmain;
    noAcc = new NewOrOldAccFrame(this);
    this.setVisible(false);
    jL_sdt.setVisible(false);
    jL_cmtnd.setVisible(false);
    jTextField_cmt.setVisible(false);
    jTextField_sdt.setVisible(false);

    jBt_dn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!jCheck_qmk.isSelected()) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(2);
                    dout.writeUTF(jTextField1.getText() + "\n" + jTextField2.getText());
                    dout.flush();
                    while (true) {
                        break;
                    }
                    DataInputStream din = new DataInputStream(client.getInputStream());
                    byte check = din.readByte();
                    if (check == 1) {
                        noAcc.setVisible(true);
                        DNFrame.this.setVisible(false);
                        noAcc.setMainCustomer(jTextField1.getText());

                    } else {
                        JOptionPane.showMessageDialog(new JFrame(),
                                "Tn ?ang Nhp Khng Tn Ti, hoac mat khau sai");
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Mng....");
                }
            } else if ((!jTextField_cmt.getText().equals("")) && (!jTextField_sdt.getText().equals(""))
                    && (NumberUtils.isNumber(jTextField_cmt.getText()))
                    && (NumberUtils.isNumber(jTextField_sdt.getText()))) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(9);
                    dout.writeUTF(jTextField1.getText() + "\n" + jTextField_sdt.getText() + "\n"
                            + jTextField_cmt.getText());
                    dout.flush();
                    DataInputStream din = new DataInputStream(client.getInputStream());
                    byte check = din.readByte();
                    if (check == 1) {
                        noAcc.setVisible(true);
                        DNFrame.this.setVisible(false);
                        noAcc.setMainCustomer(jTextField1.getText());
                    } else {
                        JOptionPane.showMessageDialog(new JFrame(), "Khong dang nhap duoc, thong tin sai");
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(new JFrame(), "Can dien day du thong tin va dung mau");
            }
        }
    });
    jBt_ql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            main.setVisible(true);
            DNFrame.this.setVisible(false);
        }
    });
    jCheck_qmk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (jCheck_qmk.isSelected()) {
                jL_sdt.setVisible(true);
                jL_cmtnd.setVisible(true);
                jTextField_cmt.setVisible(true);
                jTextField_sdt.setVisible(true);
            } else {
                jL_sdt.setVisible(false);
                jL_cmtnd.setVisible(false);
                jTextField_cmt.setVisible(false);
                jTextField_sdt.setVisible(false);
            }
        }
    });
}

From source file:App.classes.BD_Connection.java

public static Connection getConection() {
    Connection conexion = null;//  www  .  j  a  va  2 s  . c om
    try {
        conexion = Singleton_App.dataSource.getConnection();
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
    return conexion;
}

From source file:gui.sqlmap.SqlmapUi.java

private void startSqlmap() {
    String python = textfieldPython.getText();
    String workingDir = textfieldWorkingdir.getText();
    String sqlmap = textfieldSqlmap.getText();

    // Do some basic tests
    File f;/*from  w  w  w  .  j a  v a 2  s. c  o  m*/
    f = new File(python);
    if (!f.exists()) {
        JOptionPane.showMessageDialog(this, "Python path does not exist: " + python);
        return;
    }
    f = new File(workingDir);
    if (!f.exists()) {
        JOptionPane.showMessageDialog(this, "workingDir path does not exist: " + workingDir);
        return;
    }
    f = new File(sqlmap);
    if (!f.exists()) {
        JOptionPane.showMessageDialog(this, "sqlmap path does not exist: " + sqlmap);
        return;
    }

    // Write request file
    String requestFile = workingDir + "request.txt";
    try {
        FileOutputStream fos = new FileOutputStream(requestFile);
        fos.write(httpMessage.getRequest());
        fos.close();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "could not write request: " + workingDir + "request.txt");
        BurpCallbacks.getInstance().print("Error: " + e.getMessage());
    }

    // Start sqlmap
    args = new ArrayList<String>();
    args.add(python);
    args.add(sqlmap);
    args.add("-r");
    args.add(requestFile);
    args.add("--batch");

    args.add("-p");
    args.add(attackParam.getName());

    String sessionFile = workingDir + "sessionlog.txt";
    args.add("-s");
    args.add(sessionFile);
    args.add("--flush-session");

    String traceFile = workingDir + "tracelog.txt";
    args.add("-t");
    args.add(traceFile);

    args.add("--disable-coloring");
    args.add("--cleanup");

    textareaCommand.setText(StringUtils.join(args, " "));

    SwingWorker worker = new SwingWorker<String, Void>() {
        @Override
        public String doInBackground() {
            ProcessBuilder pb = new ProcessBuilder(args);
            //BurpCallbacks.getInstance().print(pb.command().toString());
            pb.redirectErrorStream(true);
            Process proc;
            try {
                proc = pb.start();

                InputStream is = proc.getInputStream();
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);

                String line;
                int exit = -1;

                while ((line = br.readLine()) != null) {
                    // Outputs your process execution
                    addLine(line);
                    try {
                        exit = proc.exitValue();
                        if (exit == 0) {
                            // Process finished
                        }
                    } catch (IllegalThreadStateException t) {
                        // The process has not yet finished. 
                        // Should we stop it?
                        //if (processMustStop()) // processMustStop can return true 
                        // after time out, for example.
                        //{
                        //    proc.destroy();
                        //}
                    }
                }
            } catch (IOException ex) {
                BurpCallbacks.getInstance().print(ex.getLocalizedMessage());
            }
            return "";
        }

        @Override
        public void done() {
        }
    };

    worker.execute();

}

From source file:net.itransformers.topologyviewer.rightclick.impl.CLIReportViewer.java

public <G> void handleRightClick(JFrame parent, String v, Map<String, String> graphMLParams,
        Map<String, String> rightClickParams, File projectPath, File versionDir) throws Exception {
    Logger logger = Logger.getLogger(CLIReportViewer.class);

    JFrame frame = new JFrame(" report for " + v + " ");
    frame.setSize(600, 400);/*ww  w  .j  av  a  2  s  .c  o m*/
    frame.getContentPane().setLayout(new BorderLayout());
    JTextPane text = new JTextPane();
    text.setEditable(true);
    text.setContentType("text/html");
    String postDiscoveryFolderPath = rightClickParams.get("post-discovery-file-path");
    String reportFileName = rightClickParams.get("reportFileName");
    logger.info("CLI report executed in " + versionDir + " for " + File.separator + postDiscoveryFolderPath
            + File.separator + v + File.separator + reportFileName);

    File xmlReport = new File(versionDir.getAbsolutePath() + File.separator + postDiscoveryFolderPath
            + File.separator + v + File.separator + reportFileName);
    if (xmlReport.exists()) {
        text.setText(FileUtils.readFileToString(xmlReport));
        JScrollPane scrollPane = new JScrollPane(text);
        frame.getContentPane().add("Center", scrollPane);
        frame.setVisible(true);

    } else {
        JOptionPane.showMessageDialog(parent, "Report does not exist! Please generate it first!");
    }
}

From source file:edu.ucla.stat.SOCR.chart.Chart.java

/**
 * make the content of the popup dialog highlightable
 * @param m/*from   www .j  av  a  2  s .c  o m*/
 */
public void showMessageDialog(String m) {
    JOptionPane popup = new JOptionPane();
    JTextArea msg = new JTextArea(m);
    Color bg = popup.getBackground();
    msg.setBackground(bg);
    popup.showMessageDialog(this, msg);
}

From source file:br.com.lnprojetos.springbootswing.ui.PessoaUI.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    Pessoa pessoa = new Pessoa("Lucas", new Date());
    pessoaRepository.save(pessoa);/*  w ww.  ja v  a2 s  .com*/
    List<Pessoa> lucases = pessoaRepository.findByNome("Lucas");
    JOptionPane.showMessageDialog(rootPane, lucases);
}

From source file:eu.ggnet.dwoss.util.HtmlDialog.java

private void search() {
    try {/*  w  w w . ja v a  2 s.  co m*/
        Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.RED);

        documentTextPane.getHighlighter().removeAllHighlights();
        StyledDocument styledDocument = documentTextPane.getStyledDocument();
        String text = styledDocument.getText(0, styledDocument.getLength());

        if (StringUtils.isBlank(text) || StringUtils.isBlank(searchField.getText()))
            return;
        int indexOf = text.indexOf(searchField.getText());

        if (indexOf == -1)
            JOptionPane.showMessageDialog(this, "Nichts gefunden.");
        while (indexOf != -1) {
            try {
                documentTextPane.getHighlighter().addHighlight(indexOf,
                        indexOf + searchField.getText().length(), painter);
                indexOf = text.indexOf(searchField.getText(), indexOf + 1);
            } catch (BadLocationException ex) {
                Logger.getLogger(HtmlDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    } catch (BadLocationException ex) {
        Logger.getLogger(HtmlDialog.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Classes.DBConnection.java

/**
 * Used to get a connection from database init
 * @return a connection to database/*from  w w w. j  a v a 2s.  c o m*/
 */
public static Connection getConnection() {
    Connection connection = null;

    try {
        connection = dataSource.getConnection();
    } catch (SQLException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e.toString());
    }

    return connection;
}

From source file:com.intuit.tank.tools.debugger.SaveTextAction.java

@Override
public void actionPerformed(ActionEvent arg0) {
    if (writer.hasData()) {
        showSaveDialog();/*from  w  w w .  j  ava2s  . c o  m*/
    } else {
        JOptionPane.showMessageDialog(parent, "There is no data to write.");
    }
}