【发布时间】:2016-11-27 17:10:07
【问题描述】:
我在FXML 中有一个TableView,我想将它的items 属性绑定到控制器中的一个列表(就像在WPF 中一样),我的FXML 代码是这样的:
<TableView fx:controller="controllers.MyController" items="$controller.loggings">
<columns>
<TableColumn text="Nom">
<cellValueFactory>
<PropertyValueFactory property="name" />
</cellValueFactory>
</TableColumn>
<TableColumn text="Type">
<cellValueFactory>
<PropertyValueFactory property="type" />
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
而我的控制器如下:
public class MyController {
public ObservableList<Logging> loggings = FXCollections.observableArrayList();
@FXML
protected void initialize(){
loggings.add(new Logging(){{
setName("hilton");
setType("hotel");
}});
}
}
由于某种原因,Exception 启动。我做错了什么?
【问题讨论】: