0
我參加了一個TableView中的代碼從一個簡單的例子ScalaFx(從ScalaFx Custom cells簡體):簡單ScalaFx的TableView例如未編譯
進口scalafx.application.JFXApp 進口scalafx.beans.property.StringProperty 進口scalafx.collections。 。ObservableBuffer 進口scalafx.scene.Scene 進口scalafx.scene.control {TableColumn中,TableView中}
object MyTableApp extends JFXApp {
class Person(nameStr : String) {
val name = new StringProperty(this, "firstName", nameStr)
}
val characters = ObservableBuffer[Person](
new Person("Peggy Sue"),
new Person("Rocky Raccoon"),
new Person("Bungalow Bill")
)
stage = new JFXApp.PrimaryStage {
title = "Simple TableView"
scene = new Scene {
content = new TableView[Person](characters) {
columns ++= List(
new TableColumn[Person, String] {
text = "First Name"
cellValueFactory = { _.value.name }
prefWidth = 100
}
)
}
}
}
}
當編譯它,我得到一個令人困惑的錯誤:
Error:(24, 11) type mismatch;
found : scalafx.scene.control.TableColumn[MyTableApp.Person,String]
required: javafx.scene.control.TableColumn[MyTableApp.Person, ?]
new TableColumn[Person, String] {
我在做什麼錯?
我build.sbt包含:
scalaVersion := "2.11.8"
libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.60-R9"