I'm implementing a searchbox.
In the textfield of the combobox I'm typing a search string. textProperty of the editor has an onChange listener which forms a list of strings that contain the text as a substring. Then I set this list of strings as a content of the drop down list of the combobox. The problem is when I start selecting items in the drop down list the editor field gets updated making new substring search and updating the list again. I want to break this dependency. I don't want to update the text property when I select an item in the drop down list OR I want to distinguish in the textProperty listener what caused that event - real editing the field or setting the field trough binding from the list view.

I hope I could make myself clear.

On 05.07.2014 01:21, Stephen F Northover wrote:
Hi Kirill,

What exactly are you trying to do?  The following (crap) listens for the
value to change and then sets it back:

         ChangeListener<String> l = new ChangeListener<String> () {
             public void changed(ObservableValue observable, String
                     String newValue) {
                 System.out.println("attempt to set new value: " +
                 Platform.runLater(() -> {
                     System.out.println("restoring old value: " +

This is not good code because it adds and removes a listener to avoid
notification when the value is reset.  It uses runLater() in order to
stop the combo box from getting confused when the value is changed from
within a changed listener.


On 2014-07-04, 3:09 PM, Kirill Kirichenko wrote:
JavaFX ComboBox has binding between TextEdit field and the ListView
selection such that edit field gets updated when we change the
selected item in the drop down list.
Is there a way to break this binding - when we select an item in the
list the editor field remains untouched. Where should I look at ?


Reply via email to