Friday, 12 September 2014

Verify Mobile Number with GUI

Structure of the Problem Requirements 

In this problem we will learn how to verify mobile number with GUI format. Before this we also upload this program in command prompt in which we discuss it now again we make it with beautiful GUI. The mobile can be verified using string matches function. String matches functions provide different type of format to validate your data. Here is the source code of this problem which help you in better understanding. 

Source Code


public class NewJFrame extends javax.swing.JFrame {

     * Creates new form NewJFrame
    public NewJFrame() {

     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();



        jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 48)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setBounds(180, 10, 170, 40);

        jLabel2.setFont(new java.awt.Font("Sylfaen", 0, 18)); // NOI18N
        jLabel2.setText("Enter Email Adress");
        jLabel2.setBounds(10, 110, 150, 30);
        jTextField1.setBounds(170, 110, 290, 30);

        jButton1.setFont(new java.awt.Font("Traditional Arabic", 0, 24)); // NOI18N
        jButton1.setText("Validate Email");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public voidactionPerformed(java.awt.event.ActionEvent evt) {
        jButton1.setBounds(90, 180, 190, 40);

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
        jTextField2.setBounds(220, 240, 190, 30);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

    }// </editor-fold>                       

    private voidjButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
          jTextField2.setText("Number Correct");
            jTextField2.setText("Number InCorrect");

    private voidjTextField2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:

     * @param args the command line arguments
    public static voidmain(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(newRunnable() {
            public void run() {
                new NewJFrame().setVisible(true);

    // Variables declaration - do not modify                    
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration                  

Output of the Program

Invalid Mobile Number
Invalid Mobile Number

Valid Mobile Number
Valid Mobile Number

Share it Please

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

1 comments: Post Yours! Read Comment Policy!▼
Important Note:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. Dear LEP, I have learned so much, please keep up the great work.w I had an interview the other day and told them how to use typedefs to save kepstrokes, to use a loop to count number of character in string, and how to create an infinite loop. I think it went well