1

I need that when checking the password, it displays "password accepted" in the console, but this does not work

controller Method:

@FXML
TextField loginfield;
@FXML
PasswordField passfield;

@FXML
public void Auth(){
    System.out.println("Login field: " + loginfield.getText());
    System.out.println("Password field: " + passfield.getText());
    if (passfield.getText() == "123") System.out.println("password accepted");
}

even that doesn't work:

@FXML
TextField loginfield;
@FXML
PasswordField passfield;
@FXML
public void Auth(){
    System.out.println("Login field: " + loginfield.getText());
    System.out.println("Password field: " + passfield.getText());
    if (passfield.getText() == passfield.getText()) System.out.println("password accepted");
}
Mya4ta
  • 13
  • 2

1 Answers1

0

You should compare like this passField.getText().equals("123") not == "123"

Even IDE complains about that :)

enter image description here

saw1k
  • 131
  • 1
  • 2