Thank you for your reply. I read through the FAQ about the UpdateManager, but I think my question is more about how DOM events are related to AWT events.
In my code both DOM and AWT events are triggered by the same mouse click, since the 'element' is also an EventTarget (whoops, should have included EventTarget element = (EventTarget) element; in the code). Here I need to ensure that mouseClicked() runs before handleEvent() (which puts the element update in the UpdateManager's queue). I guess I could set up some kind of wait()/notify() or join() scheme, but I thought there might be a "best practice" guideline for this situation. > -----Original Message----- > From: Thomas DeWeese [mailto:[EMAIL PROTECTED] > Sent: Monday, August 25, 2003 3:45 AM > To: Batik Users > Subject: Re: DOM vs. AWT Event timing > > > Grant Mc Auley wrote: > > In my code below, I want to update an Element based on the > position of > > the mouse in the JSVGCanvas. > > Please read the FAQ on the Batik site, in particular the items that > reference the UpdateManager. > > > Before adding "Thread.sleep(50)", I sometimes observed that the > > 'element' would update with an old 'xpos', i.e. apparently > the thread > > that handles DOM events ran before the AWT Event thread. > > > > My questions are: (1) am I correct in my DOM/AWT thread > diagnosis? If > > so, what is the relationship between b/w such threads? (2) > is there a > > preferred way to coordinate DOM and AWT events? (using a > Thread.sleep() > > seems like a fragile solution in an environment when many > other threads > > will be running) > > > > // ------- > > > > canvas.addMouseListener(new MouseAdapter() { > > > > public void mouseClicked(MouseEvent e) { > > xpos = e.getX(); > > ypos = e.getY(); > > } > > > > }); > > > > element.addEventListener("click", new EventListener() { > > > > public void handleEvent(Event e) { > > > > UpdateManager um = canvas.getUpdateManager(); > > um.getUpdateRunnableQueue().invokeLater(new Runnable() { > > > > public void run() { > > try { > > Thread.sleep(50); > > } > > catch (InterruptedException ex) { > > } > > > > element.setAttribute("x", Integer.toString(xpos)); > > } > > > > }); > > } > > > > } > > > > , false); > > > > // ------- > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]