我正在尝试找一些示例代码来从我的控制器内部更新我的TableView。如果可能的话,我想用fxml制作我的TableView。
def addPerson(event: ActionEvent) {
// how do I access my TableView items?
}
我的TableView看起来像:
<TableView fx:id="tableView"></TableView>
此外,交互式检查舞台对象和方法的好方法是什么?
答案 0 :(得分:2)
要使用它,您需要将其作为参数传递,如下所示:
@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
}
}