JavaFX双向绑定两个不同的非String,ListProperty

时间:2014-06-29 19:32:10

标签: binding javafx observablelist

我需要将两个ListProperties绑定在一起:

ObservableList<Data<Number, Number>>    chartDataList       = FXCollections.observableArrayList();
ListProperty<Data<Number, Number>>      chartDataProperty   = new SimpleListProperty<>(this, "chartData", chartDataList);
ObservableList<Point2D>                 observableData      = FXCollections.observableArrayList();
ListProperty<Point2D>                   dataProperty        = new SimpleListProperty<>(this, "Data", observableData);

chartDataList将用于显示LineChart,而另一个(data)将用于我的程序的其余部分。实际上并不需要chartDataProperty(但是用于绑定),因为LineChart仅使用chartDataList

注意:绑定需要是双向的,因为我有办法使用鼠标手动拖动LineChart上的点。

我没有找到直接处理此问题的方法;只有转化似乎是来自String(或ListProperty<String>)。我可以使用中间人ListProperty<String>,但看起来非常效率不高。

否则我需要使用ChangeListner用法,手动处理所有可能的情况。

请告诉我,我有更好的选择。

0 个答案:

没有答案