My window is a login form which has 2 text fields (for user name and password) and 1 button (login button).
I used NetBeans to help me designing the window and this is the actionPerformed method for the login button:
private void loginButtonActionPerformed(ActionEvent evt)
{
String password = new String(this.passwordField.getPassword());
if (this.userNameTextField.getText() == "system" && password == "admin")
{
JOptionPane.showMessageDialog(null, "good");
}
}
I debugged the application because the login button did nothing and I found out that the if sentence was not even read. But if I remove the if sentence and press the login button, the message will appear.
What am I doing wrong ?