1

我需要将两个 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>)。我可以将它与 man-in-the-middle 一起使用ListProperty<String>,但它看起来效率很低

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

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

4

0 回答 0