According to: http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#lambda-expressions-in-gui-applications
Previously:
btn.setOnActio
One way to achieve this is using implicit transformations what you need to do is to create a new Object that handles all this transformations, something like this:
import javafx.scene.input.MouseEvent
import javafx.event.EventHandler
object FXEvent2HandlerImplicits{
implicit def mouseEvent2EventHandler(event:(MouseEvent)=>Unit) = new EventHandler[MouseEvent]{
override def handle(dEvent:MouseEvent):Unit = event(dEvent)
}
}
Then just import it in any file that you may need the transformation:
import FXEvent2HandlerImplicits._
//From now on within scope you can now call events like Java8 Lambdas
chart.setOnMouseClicked( (e: MouseEvent) => println("Noice") )
This is just Syntactic sugar to archive the same thing in a more elegant way