A following code does not compile:
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.{TableColumn, TableView}
import scalafx.beans.property.StringProperty
import scalafx.scene.control.cell.TextFieldTableCell
import scalafx.Includes._ // remove this to compile OK
class Person(name_ : String) {
val name = new StringProperty(this, "firstName", name_)
}
object SimpleTableView extends JFXApp {
val characters = ObservableBuffer[Person](
new Person("Peggy"),
new Person("Rocky")
)
stage = new PrimaryStage {
title = "Simple Table View"
scene = new Scene {
content = new TableView[Person](characters) {
columns ++= List(
new TableColumn[Person, String] {
text = "First Name"
cellValueFactory = {_.value.name}
cellFactory = _ => new TextFieldTableCell[Person, String]()
prefWidth = 180
}
)
}
}
}
}
The error shown is
Error:(31, 27) missing parameter type
cellFactory = _ => new TextFieldTableCell[Person, String]()
When I remove the import scalafx.Includes._
, it compiles OK. This import is not needed in this example, but it is needed in my real code. The same error is shown when I do only a narrower import scalafx.util.UtilIncludes._
.
I guess the import brings some implicit conversion into the scope, but I do not know which. Is this perhaps a bug in ScalaFx? If not, what is the reason of this error and how can I work around it?
There was a bug in ScalaFX (#236) that was causing the issue. It is now fixed in ScalaFX v.8.0.92-R10. The code in the question should now compile and run without issues.