0

I am following this example here

object DataEditor extends JFXApp {
  val resource = getClass.getResource("MainWindowView.FXML")
  if(resource == null){
    throw new IOException("Cannot load Resource")
  }
  val root:jfxs.Parent = jfxf.FXMLLoader.load(resource)

  stage = new PrimaryStage {
    title = "Data Editor"
    scene = new Scene(root)
  }
}

but for some reason new Scene(root) doesn't work as a constructor.

Root is meant to be javafx.scene and stage.scene is scalafx.scene.Scene so making root javafx.Parent doesn't work.

Have there been any changes to scalafx since these examples have been made??

Community
  • 1
  • 1

1 Answers1

0

The answer was because I stuck stuff in the middle of SFXML and normal scalaFX

First thing I found was import scalafx.Includes._ which is the one line I managed to ignore on the examples is a "magic line" that fixes all the weirdness between javaFX and scalaFX. This fixes the No constructor errors for scene = new Scene(root)

I had an @sfxml annotation on my controller class but wasn't loading it using SFXML's FXMLView which resulted in javafx failing to find a no args constructor.

And finally FXMLView requires a Dependency resolver (I.e. Subcut) but they also have a NoDependencyResolver object to save the bacon of us mortals who don't even need one yet FXMLView(resource, NoDependencyResolver).