tags:

views:

25

answers:

1

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!

+3  A: 

Because in this way you can exactly do what you want: lister 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.

Manuel Selva
Very good!!! Thanks.
xdevel2000