如何从 scalafx 中的控制器获取 TableView 的句柄
How to get a handle to the TableView from the controller in scalafx
我试图找到一些示例代码来从我的控制器内部更新我的 TableView。如果可能的话,我想用 fxml 制作我的 TableView。
def addPerson(event: ActionEvent) {
// how do I access my TableView items?
}
我的 TableView 看起来像:
<TableView fx:id="tableView"></TableView>
此外,交互式检查阶段对象和方法的好方法是什么?
为了使用它,您需要将它作为参数传入,如下所示:
@sfxml
class PersonOverviewController(
private val tableView : TableView[S] //S -> The type of the objects contained within the TableView items list.
) {
def addPerson(event: ActionEvent) {
// do whatever you want here with tableView
val selectedIndex = tableView.selectionModel().selectedIndex.value //just for example
}
}
我试图找到一些示例代码来从我的控制器内部更新我的 TableView。如果可能的话,我想用 fxml 制作我的 TableView。
def addPerson(event: ActionEvent) {
// how do I access my TableView items?
}
我的 TableView 看起来像:
<TableView fx:id="tableView"></TableView>
此外,交互式检查阶段对象和方法的好方法是什么?
为了使用它,您需要将它作为参数传入,如下所示:
@sfxml
class PersonOverviewController(
private val tableView : TableView[S] //S -> The type of the objects contained within the TableView items list.
) {
def addPerson(event: ActionEvent) {
// do whatever you want here with tableView
val selectedIndex = tableView.selectionModel().selectedIndex.value //just for example
}
}