Re: How to send mouse event to another component?



"Rene Ruppert" <rene.ruppert@xxxxxxxxxxx> wrote:
> I have built a JPanel with lots of other small JPanels in it ("Thumbs").
> Now I would like to have all mouseDragged() events on the thumbs to be
> treated as if they happenend on the JPanel they reside in.
> I tried adding a MouseInputAdapter() to each of my thumbs but appearently
> I am missing something important since to mouseDragged() event of my
> outside JPanel is not being called. Can anybody help?
>
> public void mouseDragged(MouseEvent event)
> {
> dispatchEvent(new MouseEvent(thumbPanel,
> MouseEvent.MOUSE_DRAGGED, event.getWhen(),
> event.getModifiers(), event.getX(), event.getY(), 1,
> false));
> }
The method above is in your subclass of JPanel, or did I misunderstand you?

You probably wanted to override method
protected void processMouseMotionEvent(MouseEvent)
or
public boolean mouseDrag(Event e, int x, int y) // deprecated
of class Component.

Class JPanel has or inherits *no* method
void mouseDragged(MouseEvent e)
Hence your method overrides nothing and therefore is not called.

--
"TFritsch$t-online:de".replace(':','.').replace('$','@')







.