title: Checking of empty textbox
body: <p>I am trying to show a messagebox when either the username or password textbox is empty but when I run the project the only textbox showing is "JOptionPane.showMessageDialog(null,"Your Username or Password is incorrect");" Please help and Thank You! </p>
  
  <pre><code>private void jButton1ActionPerformed(ActionEvent evt) {                                         
    String user=txtUsername.getText();
    char[] pass=txtPassword.getPassword();
  
    if(user == null) {
      JOptionPane.showMessageDialog(null,"Username Field is empty"); 
    } else if(pass==null) {
      JOptionPane.showMessageDialog(null,"Password Field is empty");     
    } else {
      String sql="select * from account where username=? and password=?";
  
      try{
        pst=conn.prepareStatement(sql);
        pst.setString(1,txtUsername.getText());
        pst.setString(2,txtPassword.getText());
  
        rs=pst.executeQuery();
  
        if (rs.next()) {
          GridlockMain a=new GridlockMain();
          a.setVisible(true);
        } else {
          JOptionPane.showMessageDialog(null,"Your Username or Password is incorrect"); 
          txtUsername.setText(null);
          txtPassword.setText(null);
        }
      } catch (SQLException e) {
        JOptionPane.showMessageDialog(null,e); 
      }
    }
  }                                        
  </code></pre>