First the working code:
val root: BorderPane = new BorderPane(jfxf.FXMLLoader.load(getClass.getResource("/GUI/main.fxml")))
stage = new PrimaryStage()
{
title = "FXML Test"
scene = new Scene(root)
}
No problem here. Now I wanted to add i18n support like so:
val bundle: ResourceBundle = new PropertyResourceBundle(getClass.getResource("/i18n/en.properties").openStream)
val loader: FXMLLoader = new FXMLLoader(getClass.getResource("/GUI/main.fxml"), bundle)
val root = loader.load[jfxs.Parent]
stage = new PrimaryStage()
{
title = "FXML Test"
scene = new Scene(root)
}
Now the constructor scene = new Scene(root)
cannot be resolved.
I tried to solve this by
1) initializing a new BorderPane, like:
val root = new BorderPane(loader.load[jfxs.Parent])
But the constructor of BorderPane cannot be resolved so I tried
2) casting it to a BorderPane, like:
val root = new BorderPane(loader.load[jfxs.Parent].asInstanceOf[BorderPane])
which is okay in the IDE but throws a compiler-error:
Caused by: java.lang.ClassCastException: javafx.scene.layout.BorderPane cannot be cast to scalafx.scene.layout.BorderPane
How can I resolve this?