我遇到的问题是当我尝试将本教程http://www.scalafx.org/docs/faq_TableView_with_Custom_cell/中找到的代码转换为接受泛型时
到目前为止,这是我的代码
stage = new PrimaryStage {
title = "Warehouse Order Tracking System"
scene = new Scene {
content = new TableView[T](ordersList) {
val list = generateTableColums[CustomerOrder]()
columns ++= list
}
def generateTableColums[T](): List[TableColumn[T,_]] = {
List(new TableColumn[T, String] {
text = "First Name"
cellValueFactory = { _.value.asInstanceOf[Person].firstName }
prefWidth = 250
},
new TableColumn[T, String]() {
text = "Last Name"
cellValueFactory = { _.value.asInstanceOf[Person].lastName}
prefWidth = 250
}
)
}
我遇到的错误是在第5行。
type mismatch; found :List[scalafx.scene.control.TableColumn[com.qa.Entities.CustomerOrder, _]]
required:scala.collection.TraversableOnce[javafx.scene.control.TableColumn[T, _]]
非常感谢任何帮助