If I register with addMouseListener a Component and then I pass it a new MouseAdapter
the motions event aren't generated because I must use addMouseMotionListener...
and conversely if I use addMouseMotionListener with MouseAdapter I can't use click events ecc.
so really I don't understand why MouseAdapter implements also MouseMotionListener and MouseWheelListener...
it creates only confusion!
Because in this way you can exactly do what you want: listen for both 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);
This way your adapter will be notified of both Motion and clicks events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With