JavaFx:fxgraph PropertyValueFactory -> cellValueFactory
JavaFx: fxgraph PropertyValueFactory -> cellValueFactory
我在 JavaFX eclipse 项目中使用 FXGraphs。现在我想使用 TableView
。因此我写了这个 Sample.fxgraph 文件(只有 tableview 部分):
TableView < Customer > {
columns : [
TableColumn < Customer, Integer > {
text : "Id",
PropertyValueFactory < Customer, Integer > {
cellValueFactory {
property : "id"
}
}
},
TableColumn < Customer, String > {
text : "Family name",
PropertyValueFactory < Customer, String > {
cellValueFactory {
property : "familyName"
}
}
}
]
}
现在Sample.fxml文件应该是这样的(只有tableview部分):
<TableView>
<columns>
<TableColumn text="Id">
<cellValueFactory>
<PropertyValueFactory property="id" />
</cellValueFactory>
</TableColumn>
<TableColumn text="Family name">
<cellValueFactory>
<PropertyValueFactory property="familyName" />
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
但是 Sample.fxgraph[=27 中出现错误“cellValueFactory cannot be resolved to a type.” =] 文件。那不是导入问题。该程序使用正确的 fxml 文件运行。我该如何解决?
感谢阅读。
@fabian 的评论解决了这个问题
TableView < Customer > id tableView {
columns : [
TableColumn < Customer, Integer > id idTableColumn {
text : "Id",
cellValueFactory : PropertyValueFactory < Customer, Integer > {
property : "id"
}
},
TableColumn < Customer, String > {
text : "Family name",
cellValueFactory : PropertyValueFactory < Customer, String > {
property : "familyName"
}
}
]
}
我在 JavaFX eclipse 项目中使用 FXGraphs。现在我想使用 TableView
。因此我写了这个 Sample.fxgraph 文件(只有 tableview 部分):
TableView < Customer > {
columns : [
TableColumn < Customer, Integer > {
text : "Id",
PropertyValueFactory < Customer, Integer > {
cellValueFactory {
property : "id"
}
}
},
TableColumn < Customer, String > {
text : "Family name",
PropertyValueFactory < Customer, String > {
cellValueFactory {
property : "familyName"
}
}
}
]
}
现在Sample.fxml文件应该是这样的(只有tableview部分):
<TableView>
<columns>
<TableColumn text="Id">
<cellValueFactory>
<PropertyValueFactory property="id" />
</cellValueFactory>
</TableColumn>
<TableColumn text="Family name">
<cellValueFactory>
<PropertyValueFactory property="familyName" />
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
但是 Sample.fxgraph[=27 中出现错误“cellValueFactory cannot be resolved to a type.” =] 文件。那不是导入问题。该程序使用正确的 fxml 文件运行。我该如何解决?
感谢阅读。
@fabian 的评论解决了这个问题
TableView < Customer > id tableView {
columns : [
TableColumn < Customer, Integer > id idTableColumn {
text : "Id",
cellValueFactory : PropertyValueFactory < Customer, Integer > {
property : "id"
}
},
TableColumn < Customer, String > {
text : "Family name",
cellValueFactory : PropertyValueFactory < Customer, String > {
property : "familyName"
}
}
]
}