无法将MouseListener添加到PApplet

时间:2015-11-06 16:15:24

标签: java mouseevent processing mouselistener mouse-listeners

我目前正在使用PApplet处理以前编写的应用程序。 我需要我的班级将鼠标监听器附加到PApplet。我只是给我的班级引用了它的父PApplet并写了

parent.addMouseListener(new MouseListener() {
    //Implementation
}

但父母似乎对我的事件一无所知。

然后,为了测试,我尝试使用以下代码将事件直接添加到PApplet的setup方法中:

this.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent event) {
        System.out.println("Clicked");
    }
});

它给出了编译错误:

  

“Component类型中的方法addMouseListener(MouseListener)是   不适用于参数new(MouseAdapter(){})“。

我尝试使用从PApplet扩展的新创建的类相同的代码,并且它可以工作。

我想知道哪里可能出错?

0 个答案:

没有答案