Answer the question
In order to leave comments, you need to log in
Why does it give the same inscription when pressed?
Good evening!
There is a simple application
And also there is a code for it
public class Controller implements Initializable
{
public static String login = "myCat";
@FXML
private Button btn;
@FXML
private TextField loginfield;
public void initialize(URL fxmlFileLocation, ResourceBundle resources)
{
btn.setOnAction(
event ->
{
if (loginfield.getText() == login)
{
System.out.println("That's right");
}
if (loginfield.getText() != login && loginfield.getText() != null)
{
System.out.println("That's not right");
}
}
);
}
}
Answer the question
In order to leave comments, you need to log in
And if so?
if (loginfield.getText().equals(login)) {
System.out.println("That's right");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question