我想使用此动作侦听器方法检查用户名和密码,但我总是得到错误的密码!
public void actionPerformed(ActionEvent arg0) {
String uN = usernameFiled.getText();
String pass = passwordField.getPassword().toString();
//
if (uN.isEmpty() || pass.isEmpty()){
JOptionPane.showMessageDialog(LoginPage.this, "Fields should not be empty!", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
HashMap<String, User> users = UserDAO.getInstance().getUsers();
User temp = users.get(uN);
if (temp.getPassword().equals(pass)){
JOptionPane.showMessageDialog(LoginPage.this, "Login successfull", "Success", JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(LoginPage.this, "Wrong username or password", "Error ", JOptionPane.ERROR_MESSAGE);
}
}
});
代码有什么问题??