Results 1 to 2 of 2
  1. #1
    amezo15 is offline Member
    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Question Events on 2 or more objects at the same time

    Hello,
    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.

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,418
    Rep Power
    5

    Default 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.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 5
    Last Post: 02-29-2012, 10:07 AM
  2. Replies: 3
    Last Post: 08-23-2011, 12:46 PM
  3. code for moving objects at same time
    By Muhammad Assad in forum New To Java
    Replies: 13
    Last Post: 06-20-2010, 05:11 PM
  4. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 12:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •