here is a snippet from my code, my jbutton action listener
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
String username = new String(jTextuser.getText());
String password = new String(jTextpass.getText());
String passwordconfirm = new String(jTextpassconfirm.getText());
String email = new String(jTextemail.getText());
String emailconfirm= new String(jTextemailconfirm.getText());
if(username.equals("") || password.equals("") || passwordconfirm.equals("") || email.equals("") || emailconfirm.equals("")) {
JLabel errorFields = new JLabel("<HTML><FONT COLOR = Black>You must fill out all fields to complete your registration.</FONT></HTML>");
JOptionPane.showMessageDialog(null,errorFields);
jTextpass.setText("");
jTextpassconfirm.setText("");
}else if (password != passwordconfirm){
JLabel errorFields2 = new JLabel("<HTML><FONT COLOR = Black>Your password fields are not the name.</FONT></HTML>");
JOptionPane.showMessageDialog(null,errorFields2);
jTextpass.setText("");
jTextpassconfirm.setText("");
}else if (emailconfirm != email){
JLabel errorFields2 = new JLabel("<HTML><FONT COLOR = Black>Your email address fields are not the name.</FONT></HTML>");
JOptionPane.showMessageDialog(null,errorFields2);
jTextpass.setText("");
jTextpassconfirm.setText("");
}else{
JLabel errorFields2 = new JLabel("<HTML><FONT COLOR = Black>Success!</FONT></HTML>");
JOptionPane.showMessageDialog(null,errorFields2);
}
}
even when my password fields are the same, i get my message telling me that they are not?
what am i doing wrong here?