enableUnboundedMouseMovement weird behavior

Hi, I did some research in the forum but I didn't find an answer for this. When unbounded movement is enabled and the mouse event finish, the cursor returns to a position inside the component that the event first occurred on.

The weird behavior starts when I have few small children components, and their parent is a MouseListener of them. I need to do the enableUnboundedMouseMovement in the parent. But if you start clicking on one of the childs, then when the mouse event ends, it returns to a position inside the child component, what is being weird in my application.

Desktop::setMousePosition() in mouseUp() doesn't work, since it's comming before the MouseEvent dies. And I cannot use setInterceptsMouseClicks(false, false) in childrens.

Is there any way to fix this?

Not sure I totally understand what you mean, but enableUnboundedMouseMovement is only designed to be called on the actual component that is getting the events - you can't call it on the parent and expect it to work correctly.

Yes, I see. Is there a way to create an artificial MouseEvent in the parent's mouseDown/Drag/Up when you click on one of its childrens? If there ins't, I would have to convert the children to drawings in the parent, which is a lot of work.

Can't really see why that'd help, or why you'd need to do drawing in the parent..? Isn't it just a case of calling enableUnboardedMouseMovement on the correct component rather than whichever one you're currently doing it to?

I'm calling it on the right component, in this case, the parent, however once the mouseUp ends, the cursor goes back to one of its childrens.

This is the concept: I'm creating a file browser, where you can drag the components (which can reprensent a file or a folder) to another windows. You can fold and unfold folder and files, and those items are repainted if they have the mouse over them, etc. Those components are dynamic too: the file browser only generate the exact ammount of component it needs to show all the files.

But, I have another action that is scrolling all the tree structure dragging with mid mouse click. I do this action in the parent component, since the parent is a mouse listener from the children. Children simply ignore mid-mouse clicks. Then I do the enableUnboundedMouseMovement in the parent's mouseDown(). However, since the MouseEvent's originalcomponent is a child, then once the MouseEvent ends, it returns the cursor to the originalComponent (a child), instead returning it inside the component that performed the enableUnboundedMouseMovement (the parent).

If the event is being sent to its child, then you need to call it on the child, not the parent. Calling it on some other component won't do what you expect, because regardless of whether it's a mouse listener, that's not the component which is getting dragged.

It's ok - I'll try to manage it in the child. Thanks!