如果我使用addMouseListenerComponent 注册然后我传递了一个新MouseAdapter
的motions事件,因为我必须使用addMouseMotionListener...
反之,如果我用addMouseMotionListener用MouseAdapter,我不能使用点击事件ECC.
所以我真的不明白,为什么MouseAdapter还实现了MouseMotionListener与MouseWheelListener...
它只会产生混乱!
因为通过这种方式,您可以完全按照自己的意愿执行操作:在同一个侦听器类中侦听运动和单击事件:
MouseAdapter adapter = new MouseAdapter ({
// Override here all the methods you need
});
widget.addMouseListener(adapter);
widget.addMouseMotionListener(adapter);
Run Code Online (Sandbox Code Playgroud)
这样,您的适配器将收到Motion和点击事件的通知.
| 归档时间: |
|
| 查看次数: |
4048 次 |
| 最近记录: |