Class MouseAdapter and mouseMoved

If I register in a addMouseListenerComponent and then pass it a new MouseAdapter motion event is not generated, because I have to use addMouseMotionListener...

and vice versa, if I use addMouseMotionListenerc MouseAdapter, I cannot use click ecc events.

so I really don’t understand why it MouseAdapterimplements as MouseMotionListenerwell MouseWheelListener...

he only creates confusion!

+3
source share
1 answer

Because in this way you can exactly do what you want: listen for motion and click events in the same listener class:

MouseAdapter adapter = new MouseAdapter ({
    // Override here all the methods you need
});

widget.addMouseListener(adapter);    
widget.addMouseMotionListener(adapter);

Thus, your adapter will be notified of all traffic and click events.

+6

Source: https://habr.com/ru/post/1765245/


All Articles