I have a swingFX GUI and a textField where the user enters a birth-date. This textField is initialized with the string "DD.MM.YYYY". After I press the mouse button, the textField is cleared and a user can enter a birth-date-string. I just want to dispay the initialized string "DD.MM.YYYY" if the user does not enter any string iside the textField. So basically, when the textField looses its focus (no cursor is blinking) I want to check the value inside the textField and if there is no character inside (stringlength = 0), I want to change the textField back to "DD.MM.YYYY".
Here is what I have so far for clearing the textField after mouse-event was fired:
textBirthDate.setOnMouseClicked(e -> {
if(textDeathDate.getText().equals("DD.MM.YYYY")) {
textDeathDate.clear();
}
});
How to catch a focus-loosing-event? Is there such a listener? I dont want to use the mouse-exited-listener! Thanx for any help!