繁体   English   中英

如何从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 
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM