Events on 2 or more objects at the same time
I have a multi-touch screen, I want to handle 2 objects at the same time(MousePressed, MouseDragged, MouseClicked .... etc), but it when an event is being executed on one object, I cant use the other objects.
I searched for this under the multi-touch topic, but I didn't find anything.
How can I do this?
Thanks for every help.
Re: Events on 2 or more objects at the same time
I can guess at what the problem is but others may provide a better explanation.
All events are processed on the Event Dispatch Thread (EDT). So while one is being handled, the others are queued up to await their turn. This is why the events should be processed as quickly as possible, otherwise the application can become unresponsive. It seems to me that as you process events you should do the minimal prep required for the detailed processing while in the EDT and then kick off another thread to handle the larger task. However, if objects operating under multiple threads need to interact then you need to think carefully about that interaction and synchronize field and method access appropriately. Check out the tutorial in my signature. It covers thread processing and event handling.