我正在尝试向表中添加rowFactory。在Java中可以正常工作:
tableView.setRowFactory(tv -> {
TableRow<Person> row = new TableRow<>();
row.setOnMouseClicked(event -> {
System.out.println(String.format("Mouse clicked: %s", event.toString()));
});
return row;
});
我做错了什么? 但是在Kotlin中它不起作用:
tableView.rowFactory = Callback {
val row = TableRow<Person>()
row.onMouseClicked = EventHandler { mouseEvent ->
println(row.item)
}
row
}