How get an event when text in a TextField changes? JavaFX
Register a listener with the TextField
s textProperty
:
textField.textProperty().addListener((obs, oldText, newText) -> {
System.out.println("Text changed from "+oldText+" to "+newText);
// ...
});
Or Use ChangeListener
interface.
textField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
System.out.println(" Text Changed to " + newValue + ")\n");
}
});