Can't a Component be a MouseListener?


#1

I actually need that one of my component listen to mouse events on another Component, as i can’t subclass it for other reasons.

The actual MouseListener interface has the same signature to the interface of Component mouse events, so they both have mouseDown for example and i can’t make a Component a Listener of events on another one. Is it possible to change the interface of the MouseListener so to allow such a thing ?

edit: Ouch probably i’ve misunderstood, every Component is a MouseListener… ?!


#2

well yes :slight_smile:
just do component->addMouseListener(myListenerComponent);


#3

oh well, i might have been sleeping bad last night.

i was trying to do something like:

class Leet : public Component,
             public MouseListener
{
};

which leads to:

just to discover that the Component is a MouseListener itself :slight_smile: