【发布时间】:2016-08-02 22:17:18
【问题描述】:
我正在尝试为 scalafx 中完成的 Button 定义 onAction accion,但我无法使其工作。
package App.Desktop
import javafx.event.EventHandler
import scalafx.event.ActionEvent
import scalafx.scene.control.Button
class Window() {
btn_YES.onAction = (event: ActionEvent) =>
new EventHandler[ActionEvent] {
override def handle(event: ActionEvent) {
/*Do something*/
}
}
}
}
我已经这样做了,但我得到一个错误
Error: type mismatch;
found : scalafx.event.ActionEvent => javafx.event.EventHandler[scalafx.event.ActionEvent]
required: javafx.event.EventHandler[javafx.event.ActionEvent]
btn_YES.onAction = (event: ActionEvent) => new EventHandler[ActionEvent]
我也尝试使用javafx.event.ActionEvent 代替scalafx,但它也不起作用。
有什么线索吗?
谢谢
【问题讨论】: