I am trying to set a callback for a method in JavaFX: http://docs.oracle.com/javafx/2/api/javafx/fxml/FXMLLoader.html#setControllerFactory(javafx.util.Callback)
This is the signature:
public void setControllerFactory(Callback<java.lang.Class<?>,java.lang.Object> controllerFactory)
I’ve tried different kind of setups, this is the latest and I can’t seem to get it to compile at all, there’s always something that doesn’t match the signature:
val loader = new FXMLLoader()
loader.setControllerFactory(new Callback[Class[_], AnyRef] {
})
This one gives me:
error: object creation impossible, since method call in trait Callback of type (x$1: Class[_])AnyRef is not defined
How would I write that Java example in Scala?
As the error message says, you need to define that method in your anonymous class: