I wrote this little piece of code in javafx:
tfb.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle (ActionEvent e) {
if(tf1.getText() == "test") {
System.out.println("correct");
} else {
System.out.println("wrong");
}
}
});
When i enter test in the textfield, i always get a "wrong", not a "correct" as ist should be. I checked several times wether i spelles "test" correctly, and i also tried to put test in quotation marks (them: " and them: '), none of this helped.
I already tried to print out the content of the textfield (with System.out.Println(tf1.getText())), and i got what i wrote in the textfield on the console, so the action listener and tf1.getText() works for shure.
Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire