samedi 14 décembre 2019

ELSE STATEMENT PROCEEDS TO EXECUTE EVEN IF STATEMENTS ARE ENCOUNTERED

I am working in Java and I have come across a trouble in my code where I have multiple if statements and one else. Despite the if statements being true, the else statements still execute. I've been encountering this all day and I can't seem to find the error. If anyone can help

private void confirmActionPerformed(java.awt.event.ActionEvent evt) {                                       

    if(lname1.getText().equals("")){
         lname_ver1.setText("Field is empty!");

     }
    if (mname1.getText().equals("")){
        mname_ver1.setText("Field is empty!");

    }
    if(fname1.getText().equals("")){
       fname_ver.setText("Field is empty!");

    }
     if(s_age.getSelectedIndex()== 0){
     age_ver.setText("Field is empty!");
    }
    if(!female_button.isSelected()&& !male_button.isSelected()){
    gender_ver1.setText("Select gender!");
    }
    if(month.getSelectedIndex()==0 && day.getSelectedIndex()==0 && year.getSelectedIndex()==0){
            birth_ver1.setText("Field is empty!");
            }

    if (s_num.getText().equals("")){
          num_ver.setText("Field is empty!"); 

    }


     if(!email.getText().matches("\"^[a-zA-Z0-9]+[@]+[a-zA-Z0-9]+[.]+[a-zA-Z0-9]+$")){
       email_ver1.setText("Invalid email!");
     }
     if(email.getText().equals("")){
        email_ver1.setText("Field is empty!");

     if(fathers_name.getText().equals("")){
        father_ver1.setText("Field is empty!")
    }
     if(mothers_name.getText().equals("")){
     mother_ver1.setText("Field is empty!");   
    }
     if(parent_no.getText().equals("")){
     no_verify1.setText("Field is empty!");  
     }
     if(parent_no.getText().contains("[a-zA-Z]")){
         no_verify1.setText("Field is empty!");
     }

     if (s_nat.getText().equals("")){
      nat_ver.setText("Field is empty!");
     }
     if(!single.isSelected() && married.isSelected()){
            nat_ver.setText("Select status!!");
     }



   else
    {
        JOptionPane.showMessageDialog(null, "SUCCESS", "INFO    ", JOptionPane.INFORMATION_MESSAGE);
        dispose();
        Schedule sched = new Schedule();
        sched.setLocationRelativeTo(null);
        sched.setResizable(false);
        sched.setVisible(true);
    }`

Aucun commentaire:

Enregistrer un commentaire