Skip to content

Importing scalafx.Includes._ breaks cellFactory creation #236

Description

@OndrejSpanel

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._ // does not compile
//import scalafx.util.UtilIncludes.function12jfxCallback // does not compile
//import scalafx.Includes.{function12jfxCallback => _, _} // compiles 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 is

Error:(34, 27) missing parameter type
cellFactory = _ => new TextFieldTableCell[Person, String]()

As a workaround one can disable import of function12jfxCallback, as indicated in the source comments.

I am not sure what can be done to fix this, but the error was confusing and it was quite hard to identify the exact cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions