【问题标题】:Javafx Image as buttonJavafx 图像作为按钮
【发布时间】:2015-02-09 15:34:08
【问题描述】:

我想将图像设置为按钮,但总是出现以下错误:

绑定不匹配:MouseEvent 类型不是 EventHandler 类型的绑定参数的有效替代品

@FXML ImageView imgReturn;

    public void initialize(URL arg0, ResourceBundle arg1) {

    imgReturn.setOnMouseClicked(new EventHandler<MouseEvent>()
                @Override
                public void handle(MouseEvent ev)
                {

                }
    );

【问题讨论】:

标签: image button javafx


【解决方案1】:

只需检查您的导入。

你用错了MouseEvent

import java.awt.event.MouseEvent;

您应该使用 JavaFX 代替:

import javafx.scene.input.MouseEvent;

【讨论】:

    猜你喜欢
    • 2020-03-19
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 2021-06-01
    • 1970-01-01
    • 2018-06-04
    相关资源
    最近更新 更多