【发布时间】:2023-03-12 21:32:01
【问题描述】:
我有一个包含数据的 TableView,并且想要一个 PieChart 来可视化该表中的数据。我不明白我应该如何将数组列表从 TableView 绑定到 Piechart,因为 TableView 需要 getter 和 setter,而 piechart 需要 PieChart.Data 可观察列表。
这是我目前的代码,元素是用 Scene Builder 设计的
@FXML
private TableView<Record> tableView;
static ObservableList<Record> dataen
= FXCollections.observableArrayList(
new Record("January", 100),
new Record("February", 200));
public void initialize(URL url, ResourceBundle rb) {
Month.setCellValueFactory(new PropertyValueFactory("fieldMonth"));
Value.setCellValueFactory(new PropertyValueFactory("fieldValue"));
tableView.setItems(dataen);
}
}
【问题讨论】:
-
Oracle sample 在桌子上使用监听器。
-
我见过这个,但在我的例子中它根本没有帮助我。我正在使用场景生成器,问题是我无法将可观察列表“dataen”设置为 PieChart..
标签: javafx