How get an event when text in a TextField changes? JavaFX

void picture void · Jul 12, 2015 · Viewed 26.3k times · Source

How can I generate a new event to handle whenever TextField's text is changed?

Answer

Isthatso picture Isthatso · Jul 12, 2015

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");
    }
});