ComboBox: TestEditor to ListView binding
Stephen F Northover
steve.x.northover at oracle.com
Fri Jul 4 21:21:31 UTC 2014
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
oldValue,
String newValue) {
System.out.println("attempt to set new value: " +
newValue);
Platform.runLater(() -> {
comboBox3.valueProperty().removeListener(this);
System.out.println("restoring old value: " + newValue);
comboBox3.setValue(oldValue);
comboBox3.valueProperty().addListener(this);
});
};
};
comboBox3.valueProperty().addListener(l);
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.
Steve
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 ?
>
>
> Thanks.
> K
More information about the openjfx-dev
mailing list