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

private InputVerifier getInputVerifier() {
    InputVerifier verifier = new InputVerifier() {
        @Override/*  w  w w  .  j  ava  2s  . c  o m*/
        public boolean verify(JComponent input) {
            JFormattedTextField field = (JFormattedTextField) input;
            String text = field.getText();
            return isValidDate(text);
        }

        @Override
        public boolean shouldYieldFocus(JComponent input) {
            boolean valid = verify(input);
            if (!valid) {
                JOptionPane.showMessageDialog(null, "Please enter a valid date in format dd/mm/yyyy");
            }
            return valid;
        }
    };
    return verifier;
}

From source file:customize.swing.startMain.java

public startMain() {
    initComponents();//from w  w w . ja  va  2  s.  c om
    initComponents();
    jfc.setCurrentDirectory(new File("d://"));// ?d
    genButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //
            String text = TextField.getText();
            //?
            String text1 = textField3.getText();
            if (StringUtils.isBlank(text)) {
                JOptionPane.showMessageDialog(null, "??!!");
                return;
            }
            if (StringUtils.isBlank(text1)) {
                JOptionPane.showMessageDialog(null, "??!!");
                return;
            }
            if (StringUtils.isBlank(rootTextField.getText())) {
                JOptionPane.showMessageDialog(null, "???!!");
                return;
            }
            if (StringUtils.isBlank(PasswordField.getText())) {
                JOptionPane.showMessageDialog(null, "??!!");
                return;
            }
            if (StringUtils.isBlank(textField8.getText())) {
                JOptionPane.showMessageDialog(null, "???!!");
                return;
            }
            if (StringUtils.isBlank(textField2.getText())) {
                JOptionPane.showMessageDialog(null, "?!!");
                return;
            }

            String xml = "";
            String model = "";
            String dao = "";

            xml = textField6.getText();
            model = textField7.getText();
            dao = textField1.getText();

            if (StringUtils.isBlank(xml)) {
                xml = "./";
            }
            if (StringUtils.isBlank(model)) {
                model = "./";
            }
            if (StringUtils.isBlank(dao)) {
                dao = "./";
            }

            RequestModel requestModel = new RequestModel();
            requestModel.setDriverClass(text);
            requestModel.setConnectionURL(text1);
            requestModel.setUserId(rootTextField.getText());
            requestModel.setPassword(PasswordField.getText());
            requestModel.setTableName(textField8.getText());
            requestModel.setProjectPath(textField2.getText());
            requestModel.setXmlPackage(xml);
            requestModel.setModelPackage(model);
            requestModel.setInterfacePackage(dao);

            if (CheckBox1.isSelected()) {
                requestModel.setUseActualColumnNames(false);
            }

            if (!CheckBox2.isSelected()) {
                requestModel.setSuppressAllComments(false);
            }

            GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap();
            try {
                generatorSqlmap.generator(requestModel);
                JOptionPane.showMessageDialog(null, "?~");
                File file = new File(textField2.getText());
                java.awt.Desktop.getDesktop().open(file.getParentFile());
            } catch (Exception e1) {
                JOptionPane.showMessageDialog(null, "~  :" + e1.getMessage());
                e1.printStackTrace();
            }

        }
    });
    ButtonView.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource().equals(ButtonView)) {// ?
                setTextValue(textField2);
            }
        }
    });

}

From source file:bankingclient.TaoTaiKhoanFrame.java

public TaoTaiKhoanFrame(NewOrOldAccFrame acc) {

    initComponents();// ww  w.j  av a 2  s.  c  om
    this.jText_ten_tk.setText("");
    this.jText_sd.setText("");

    this.noAcc = acc;
    this.mainCustomerName = null;
    this.setVisible(false);

    jBt_ht.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (NumberUtils.isNumber(jText_sd.getText()) && (Long.parseLong(jText_sd.getText()) > 0)) {
                try {
                    Socket client = new Socket("113.22.46.207", 6013);
                    DataOutputStream dout = new DataOutputStream(client.getOutputStream());
                    dout.writeByte(3);
                    dout.writeUTF(jText_ten_tk.getText() + "\n" + mainCustomerName + "\n" + jText_sd.getText());
                    dout.flush();
                    DataInputStream din = new DataInputStream(client.getInputStream());
                    byte check = din.readByte();
                    if (check == 1) {
                        JOptionPane.showMessageDialog(rootPane, "da tao tai khoan thanh cong");
                    } else {
                        JOptionPane.showMessageDialog(rootPane, "tao tai khoan khong thanh cong");
                    }
                    client.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                noAcc.setVisible(true);
                TaoTaiKhoanFrame.this.setVisible(false);
            } else {
                JOptionPane.showMessageDialog(rootPane, "Can nhap lai so tien gui");
            }

        }
    });
    jBt_ql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            noAcc.setVisible(true);
            TaoTaiKhoanFrame.this.setVisible(false);

        }
    });
}

From source file:mysynopsis.JSONWriter.java

public static void writeData() throws IOException {

    JSONObject bio = new JSONObject();
    bio.put("Name", name);
    bio.put("Initial", initial);
    bio.put("Bio", biog);
    bio.put("Designation", designation);
    bio.put("Department", dept);
    bio.put("University", university);
    bio.put("University_Address", universityAddress);
    bio.put("Office", office);
    bio.put("Ohours", officehours);
    bio.put("Phone", phone);
    bio.put("Email", email);
    bio.put("Resume_Link", resumelink);
    bio.put("Educational", education);
    bio.put("Professional", professional);

    bio.put("Awards", awards);

    bio.put("Image_Ext", imgExtension);
    bio.put("Image_String", imgString);

    /*JSONArray education = new JSONArray();
    for(int i=0;i<8;i++) {/*from  w w  w  .ja v  a  2 s . c  o m*/
    education.add(educ[i]);
    }
    bio.put("Education",education);*/

    JSONArray ftpinfo = new JSONArray();

    ftpinfo.add(server);
    ftpinfo.add(user);
    ftpinfo.add(dir);

    bio.put("Server_Information", ftpinfo);

    try (FileWriter file = new FileWriter("data.json")) {

        file.write(bio.toJSONString());
    } catch (IOException e) {

        JOptionPane.showMessageDialog(null,
                "Can't Create Data.json File. Please Check Your Directory Permission");
    }
}

From source file:Main.java

public Main() {
    listener = new DocumentListener() {
        Document source = null;//  w w w  . j a v  a2 s . c  o m

        protected void update(Document doc) {
            if (source == null) {
                System.out.println("Update");
                source = doc;
                if (source.equals(input.getDocument())) {
                    input2.setText(input.getText());
                } else if (source.equals(input2.getDocument())) {
                    input.setText(input2.getText());
                }
                source = null;
            }
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            update(e.getDocument());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            update(e.getDocument());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            update(e.getDocument());
        }
    };

    input.getDocument().addDocumentListener(listener);
    input2.getDocument().addDocumentListener(listener);

    input.setColumns(4);
    input2.setColumns(4);

    input.setValue(0.0);
    JPanel panel = new JPanel();
    panel.add(input);
    panel.add(input2);

    JOptionPane.showMessageDialog(null, panel);
}

From source file:Main.java

ScreenCaptureRectangle(final BufferedImage screen) {
    BufferedImage screenCopy = new BufferedImage(screen.getWidth(), screen.getHeight(), screen.getType());
    JLabel screenLabel = new JLabel(new ImageIcon(screenCopy));
    JScrollPane screenScroll = new JScrollPane(screenLabel);

    screenScroll.setPreferredSize(new Dimension(300, 300));

    repaint(screen, screenCopy);//from  w w  w  .j a v  a 2s  .  c  o m
    screenLabel.repaint();

    screenLabel.addMouseMotionListener(new MouseMotionAdapter() {
        Point start = new Point();

        @Override
        public void mouseMoved(MouseEvent me) {
            start = me.getPoint();
            repaint(screen, screenCopy);
            screenLabel.repaint();
        }

        @Override
        public void mouseDragged(MouseEvent me) {
            Point end = me.getPoint();
            captureRect = new Rectangle(start, new Dimension(end.x - start.x, end.y - start.y));
            repaint(screen, screenCopy);
            screenLabel.repaint();
        }
    });
    JOptionPane.showMessageDialog(null, screenScroll);
}

From source file:application.bbdd.pool.java

public static void realizaConsulta1() {
    Connection conexion = null;/*from   w w  w.  java  2s .c  o m*/
    Statement sentencia = null;
    ResultSet rs = null;

    try {
        // BasicDataSource nos reserva una conexion y nos la devuelve
        conexion = getConexion();
        sentencia = conexion.createStatement();
        rs = sentencia.executeQuery("select count(*) from user");
        rs.next();
        JOptionPane.showMessageDialog(null, "El numero de usuarios es: " + rs.getInt(1));
        logStatistics();

    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e.toString());
    } finally {
        try {
            rs.close();
            sentencia.close();
            liberaConexion(conexion);
        } catch (Exception fe) {
            JOptionPane.showMessageDialog(null, fe.toString());
        }
    }
}

From source file:MstrKasMasuk.Entry.java

private void Search() {
    try {// w ww .  j  a  v a  2 s. c  o  m
        MstrKasMasuk x = new MstrKasMasuk();
        x.Search(_ID);
        if (x._Akses.equals("-")) {
            txt_id.setText(x.id);
            String tgl = StringUtils.substringBeforeLast(x.tgl, " ");
            txt_tgl_masuk.setDate(java.sql.Date.valueOf(tgl));
            txt_ket.setText(x.ket);
            txt_jum.setText(x.jum_uang);
            txt_id.setEditable(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

From source file:eu.ggnet.dwoss.report.CreateViewCask.java

@Override
public boolean onOk() {
    if (!StringUtils.isNotBlank(nameTextField.getText())) {
        JOptionPane.showMessageDialog(this, "Der Name ist leer.");
        return false;
    }/*from w  w w .  ja v a  2  s . c o m*/
    if (endDateChooser.getDate() == null) {
        JOptionPane.showMessageDialog(this, "Das Enddatum wurde nicht ausgewhlt.");
        return false;
    }
    if (startDateChooser.getDate() == null) {
        JOptionPane.showMessageDialog(this, "Das Startdatum wurde nicht ausgewhlt.");
        return false;
    }
    if (startDateChooser.getDate().after(endDateChooser.getDate())) {
        JOptionPane.showMessageDialog(this, "Das Startdatum ist nach dem Enddatum.");
        return false;
    }
    return true;
}

From source file:MstrKasKeluar.Entry.java

private void Search() {
    try {/*from  w w w .java  2  s  .co  m*/
        MstrKasKeluar x = new MstrKasKeluar();
        x.Search(_ID);
        if (x._Akses.equals("-")) {
            txt_id.setText(x.id);
            String tgl = StringUtils.substringBeforeLast(x.tgl, " ");
            txt_tgl_keluar.setDate(java.sql.Date.valueOf(tgl));
            txt_ket.setText(x.ket);
            txt_jum.setText(x.jum_uang);

            txt_id.setEditable(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}