Fist, when working with ScalaFX, it is important to import scalafx.Includes._ . It brings many of the features of ScalaFX.
There are two recommended ways to add an onAction handler. The main (event:ActionEvent) => { ... ) is to use closure (event:ActionEvent) => { ... ) :
import scalafx.Includes._ import scalafx.event.ActionEvent btn_YES.onAction = (event: ActionEvent) => { /*Do something*/ }
If you do not need an event object. You can save some typing and use handle {...} :
import scalafx.Includes._ btn_YES.onAction = handle { /*Do something*/ }
In both cases, you need to import scalafx.Includes._
Jarek source share