myButton.addActionListener(this);
myFrame.addMouseMotionListener(this);
myFrame.addMouseListener(this);
myFrame.addWindowListener(this);
myButton.addActionListener(this);
myFrame.addMouseMotionListener(this);
myFrame.addMouseListener(this);
我说的是这种形式的,这些方法仅仅是想要调用当前类的从接口那里得来的方法(在这个类中已经实现了)为什么不是this.方法名称?而是单独一个this?
为什么不是this. 因为这个方法是要传入一个实现了该接口的一个类的对象。而this.是传入一个方法当然就不行了。这是面相对象多态的知识
setlistener要求传入的是个接口,又不是方法。而this类应该实现了这个接口所以你传入this就可以了
因为它需要的参数就是本类的指针