I am just trying to get familiar with ScalaFX, and my Scala knowledge is also still in embryo phase. Can you please help me out, in the following simple problem?
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.collections.ObservableBuffer
import scalafx.scene.Scene
import scalafx.scene.control.TableColumn._
import scalafx.scene.control.{TableCell, TableColumn, TableView}
object Gui extends JFXApp {
case class listInfo(text: String, subtexts: List[String], thumbnail: String, attributeField: Int)
val demo = ObservableBuffer[listInfo](
new listInfo("dewdfasc", subtexts = List("first", "second"), "tdsam", 1),
new listInfo("hgfhfghn", subtexts = List("first", "second"), "tdsacdsm", 2)
)
stage = new PrimaryStage {
title = "ScalaFX Hello World"
scene = new Scene {
root = TableView[listInfo](demo) {
columns ++= List(
new TableColumn[listInfo, String] {
text = "band"
cellValueFactory = {_.value.text}
prefWidth = 100
},
new TableColumn[listInfo, String] {
text = "thumbnail"
cellValueFactory = {_.value.thumbnail}
prefWidth = 100
}
)
}
}
}
}
has the following compiler error:
Error:(20, 23) object TableView does not take type parameters.
root = TableView[listInfo](demo) {
Error:(21, 9) not found: value columns
columns ++= List(
Error:(24, 41) type mismatch;
found : String
required: scalafx.beans.value.ObservableValue[String,String]
cellValueFactory = {_.value.text}
Error:(29, 41) type mismatch;
found : String
required: scalafx.beans.value.ObservableValue[String,String]
cellValueFactory = {_.value.thumbnail}
my environment:
java 1.8
scala 2.12
scalafx 2.11-8.0.144-R12
What should I correct, so that it compiles?
Thanks in advance!