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:com.litt.core.security.license.gui.CustomerPanel.java

private void initProduct() {
    try {//w  w w  . j a  v  a2 s . c o m
        //???
        comboBoxProduct.removeAllItems();

        comboBoxProduct.addItem("...");

        File configFile = new File(Gui.HOME_PATH, "config.xml");

        Document document = XmlUtils.readXml(configFile);
        Element rootE = document.getRootElement();
        List<Element> productNodeList = rootE.elements();
        for (Element productNode : productNodeList) {
            String productCode = productNode.attributeValue("code");
            String productName = productNode.attributeValue("name");
            comboBoxProduct.addItem(productCode + "-" + productName);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e.getMessage());
    }
}

From source file:Classes.DBConnection.java

/**
 * Used to release connection//from ww  w  .  j  av a2 s.co m
 * @param connection is the connection to release
 */
public static void releaseConnection(Connection connection) {
    try {
        if (null != connection)
            // En realidad no cierra, solo libera la conexion.
            connection.close();
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:bankingclient.ChonThaoTacFrame.java

public ChonThaoTacFrame(NewOrOldAccFrame acc) {
    initComponents();// w  w w  . j a  v  a2 s  .c o m
    jTextField1.setText("");

    jLabel4.setVisible(false);
    jComboBox2.setVisible(false);
    jLabel2.setVisible(false);
    jLabel3.setVisible(false);
    jTextField1.setVisible(false);
    jBt_xn1.setVisible(false);
    jBt_xn2.setVisible(false);

    this.accList = null;
    this.cusList = null;
    this.noAcc = acc;
    this.tt = new Thong_Tin_TK(this);
    this.setVisible(false);

    jBt_xn1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (NumberUtils.isNumber(jTextField1.getText()) && (Long.parseLong(jTextField1.getText()) > 0)) {
                long currentMoney = 0;
                try {
                    Socket client = new Socket("113.22.46.207", 6013);

                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(8);
                    dout.writeUTF((String) jComboBox1.getSelectedItem());
                    dout.flush();

                    DataInputStream din = new DataInputStream(client.getInputStream());
                    Scanner lineScanner = new Scanner(din.readUTF());
                    currentMoney = Long.parseLong(lineScanner.nextLine());
                    System.out.println(currentMoney);

                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(rootPane,
                            "Li kt ni mng,bn cn kim tra kt ni");
                }

                if (jCheck_gt.isSelected()) {
                    try {
                        Socket client = new Socket("113.22.46.207", 6013);
                        DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                        dout.writeByte(5);
                        dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n" + jTextField1.getText()
                                + "\n" + (noAcc.getCustomer()));
                        dout.flush();

                    } catch (Exception ex) {
                        ex.printStackTrace();
                        JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Xy ra....");
                    }
                    JOptionPane.showMessageDialog(rootPane, "Gi Ti?n Thnh Cng...");
                }

                if (jCheck_rt.isSelected()) {
                    if ((Long.parseLong(jTextField1.getText()) <= currentMoney)) {
                        try {
                            Socket client = new Socket("113.22.46.207", 6013);
                            DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                            dout.writeByte(6);
                            dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n" + jTextField1.getText()
                                    + "\n" + (noAcc.getCustomer()));
                            dout.flush();

                        } catch (Exception ex) {
                            ex.printStackTrace();
                            JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Xy Ra.....");
                        }
                        JOptionPane.showMessageDialog(rootPane, "Rt Ti?n Thnh Cng ...");
                    } else {
                        System.out.println("Khng  Ti?n Trong ti khon.." + currentMoney);
                        JOptionPane.showMessageDialog(null, "Ti Khon Khng ? ? Rt ...");
                    }
                }

                noAcc.setVisible(true);
                ChonThaoTacFrame.this.setVisible(false);
            } else {
                JOptionPane.showMessageDialog(rootPane,
                        "Cn Nhp Li S Ti?n Cn Gi Hoc Rt..");
            }

        }
    });

    jBt_tt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tt.setTk((String) jComboBox1.getSelectedItem());
            tt.hienTenTk();
            long currentMoney = 0;
            try {
                Socket client = new Socket("113.22.46.207", 6013);

                DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                dout.writeByte(8);
                dout.writeUTF((String) jComboBox1.getSelectedItem());
                dout.flush();

                DataInputStream din = new DataInputStream(client.getInputStream());
                Scanner lineScanner = new Scanner(din.readUTF());
                currentMoney = Long.parseLong(lineScanner.nextLine());
                //                    System.out.println(currentMoney);

            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(rootPane,
                        "Li kt ni mng,bn cn kim tra kt ni");
            }
            tt.hienSoDu(((Long) currentMoney).toString());
            tt.setVisible(true);
            try {
                Socket client = new Socket("113.22.46.207", 6013);

                DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                dout.writeByte(10);
                dout.writeUTF((String) jComboBox1.getSelectedItem());
                dout.flush();

                DataInputStream din = new DataInputStream(client.getInputStream());
                Scanner cusScanner = new Scanner(din.readUTF());
                while (cusScanner.hasNextLine()) {
                    tt.addCus(cusScanner.nextLine());
                }
            } catch (Exception ee) {
                ee.printStackTrace();
            }
            tt.hienChuTaiKhoan();
            try {
                Socket client = new Socket("113.22.46.207", 6013);
                DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                dout.writeByte(12);
                dout.writeUTF((String) jComboBox1.getSelectedItem());
                dout.flush();

                DataInputStream din = new DataInputStream(client.getInputStream());
                Scanner dateScanner = new Scanner(din.readUTF());
                int day = Integer.parseInt(dateScanner.nextLine());
                int month = Integer.parseInt(dateScanner.nextLine());
                int year = Integer.parseInt(dateScanner.nextLine());
                String date = (day + "-" + month + "-" + year);
                tt.hienNgayLapTaiKhoan(date);
                while (dateScanner.hasNextLine()) {
                    //                        System.out.println("aaa");
                    tt.addGiaoDich(dateScanner.nextLine());
                }
                tt.hienGiaoDich();
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            ChonThaoTacFrame.this.setVisible(false);
        }
    });

    jBt_xn2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jCheck_tctk.isSelected()) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(7);
                    dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n"
                            + (String) jComboBox2.getSelectedItem());
                    dout.flush();
                } catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(rootPane,
                            "C Li Kt Ni Xy Ra\n Thm Ch Tht Bi...");
                }
                JOptionPane.showMessageDialog(rootPane, "Thm Ch Ti Khon Thnh Cng..");
            } else {
                System.out.println("nothing to do...");
            }
        }
    });

    jBt_xtk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Socket client = new Socket("113.22.46.207", 6013);
                DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                dout.writeByte(11);
                String sent = (String) (jComboBox1.getSelectedItem()) + "\n" + noAcc.getCustomer();
                dout.writeUTF(sent);
                dout.flush();
                DataInputStream din = new DataInputStream(client.getInputStream());
                byte check = din.readByte();
                if (check == 1) {
                    JOptionPane.showMessageDialog(rootPane, "xoa tai khoan thanh cong");
                } else {
                    JOptionPane.showMessageDialog(rootPane,
                            "<html>xoa tai khoan <b>khong</b> thanh cong <br> chi chu chinh moi co the xoa tai khoan</html>");
                }

            } catch (Exception ee) {
                ee.printStackTrace();
                JOptionPane.showMessageDialog(rootPane, "Li Kt Ni ,Vui Lng Kim Tra Li..");
            }
        }
    });

    /*dont touch*/
    jBt_ql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            noAcc.setVisible(true);
            ChonThaoTacFrame.this.setVisible(false);
        }
    });
    /*dont touch*/

    jComboBox1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

        }
    });

    jComboBox2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

        }
    });

    /*dont touch jcheckbox*/
    jCheck_tctk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jCheck_tctk.isSelected()) {
                jLabel4.setVisible(true);
                jComboBox2.setVisible(true);
                jBt_xn2.setVisible(true);
            } else {
                jLabel4.setVisible(false);
                jComboBox2.setVisible(false);
                jBt_xn2.setVisible(false);
            }
        }
    });
    jCheck_gt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jCheck_gt.isSelected()) {
                if (jCheck_rt.isSelected()) {
                    jCheck_rt.setSelected(false);
                }
                jLabel2.setVisible(true);
                jLabel3.setVisible(true);
                jTextField1.setVisible(true);
                jBt_xn1.setVisible(true);
            } else {
                jLabel2.setVisible(false);
                jLabel3.setVisible(false);
                jTextField1.setVisible(false);
                jBt_xn1.setVisible(false);
            }
        }
    });
    jCheck_rt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jCheck_rt.isSelected()) {
                if (jCheck_gt.isSelected()) {
                    jCheck_gt.setSelected(false);
                }
                jLabel2.setVisible(true);
                jLabel3.setVisible(true);
                jTextField1.setVisible(true);
                jBt_xn1.setVisible(true);
            } else {
                jLabel2.setVisible(false);
                jLabel3.setVisible(false);
                jTextField1.setVisible(false);
                jBt_xn1.setVisible(false);
            }
        }
    });
    /*dont touch jcheckbox*/
}

From source file:PrintTest.java

public PrintTestFrame() {
    setTitle("PrintTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    canvas = new PrintComponent();
    add(canvas, BorderLayout.CENTER);

    attributes = new HashPrintRequestAttributeSet();

    JPanel buttonPanel = new JPanel();
    JButton printButton = new JButton("Print");
    buttonPanel.add(printButton);// w  w w .  j  a v a 2 s  .  c o m
    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                PrinterJob job = PrinterJob.getPrinterJob();
                job.setPrintable(canvas);
                if (job.printDialog(attributes))
                    job.print(attributes);
            } catch (PrinterException e) {
                JOptionPane.showMessageDialog(PrintTestFrame.this, e);
            }
        }
    });

    JButton pageSetupButton = new JButton("Page setup");
    buttonPanel.add(pageSetupButton);
    pageSetupButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.pageDialog(attributes);
        }
    });

    add(buttonPanel, BorderLayout.NORTH);
}

From source file:controller.model.ControllerPsUsuarios.java

public Boolean acceso(PsUsuarios usuario) {
    ctrlUsuariosJpaController = new PsUsuariosJpaController();
    Boolean acceso;// ww  w  . j  av a 2  s .  co m

    if (usuario != null) {
        sessionUsuario = ctrlUsuariosJpaController.getUsuario(usuario);
        acceso = validarUsuario(sessionUsuario);
        if (acceso == true) {

            JOptionPane.showMessageDialog(null,
                    "Bienvenido Sr(a). " + sessionUsuario[4] + " " + sessionUsuario[5]);

        } else {
            JOptionPane.showMessageDialog(null, "Datos incorrectos");
            return false;
        }

    } else {

        return false;
    }

    return true;
}

From source file:MstrPetugas.FormPetugas.java

private void LoadData() {
    try {//from  w w w .  j  a va2s. c  o  m
        _Cnn = null;
        DbKoneksi getCnn = new DbKoneksi();
        _Cnn = getCnn.getConnection();
        HapusTabel();
        String sql = "" + "   SELECT id_petugas,nama,no_telepon" + "   FROM petugas";

        Statement stat = _Cnn.createStatement();
        ResultSet res = stat.executeQuery(sql);
        while (res.next()) {
            String id_petugas = res.getString(1);
            String nama = res.getString(2);
            String status = res.getString(3);
            Object[] data = { id_petugas, nama, status };
            _Tampung_tabel_mstr_petugas.addRow(data);
        }
        tabel_petugas.getColumnModel().getColumn(0).setPreferredWidth(10);
        tabel_petugas.getColumnModel().getColumn(1).setPreferredWidth(50);
        tabel_petugas.getColumnModel().getColumn(2).setPreferredWidth(50);

    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "Error : " + ex);
    }
}

From source file:frames.consulta.java

void cargartablapacientes(String valor) {
    String[] titulos = { "Cedula", "Nombre", "Apellido", "Edad", "Direccion" };
    String[] registro = new String[5];
    modelo = new DefaultTableModel(null, titulos);

    String sSQL = "";
    if (valor.equals("")) {
        sSQL = "SELECT * FROM pacientes";
    } else {//from   w ww  . j av  a 2  s.c o m
        sSQL = "SELECT * FROM pacientes WHERE " + atributo + " LIKE '%" + valor + "%'";

    }

    try {
        Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery(sSQL);

        while (rs.next()) {

            registro[0] = rs.getString("cedula");
            registro[1] = rs.getString("nombre");
            registro[2] = rs.getString("apellido");
            registro[3] = rs.getString("edad");
            registro[4] = rs.getString("direccion");
            modelo.addRow(registro);
        }

        tblconsulta.setModel(modelo);
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, ex);
    }

}

From source file:userinterface.PatientRole.PatientLikeMeJPanel.java

public void deleteWorkRequests() {

    int l = userAccount.getWorkQueue().getWorkRequestList().size();
    while (l != 0) {
        userAccount.getWorkQueue().getWorkRequestList().remove(l - 1);
        l--;/*from  w w  w  .ja va 2  s.  co  m*/
    }
    JOptionPane.showMessageDialog(null, userAccount.getWorkQueue().getWorkRequestList());

}