[XML][SVG]How to add an EventListener to every element?

  • Thread starter Michael Holtermann
  • Start date
M

Michael Holtermann

Hi!

I've integrated a SVG graphic with the batik toolkit in a JPanel. Now I'd
like to add an org.w3c.dom.events.EventListener to every Element.

If I call the method like the following:
<code>
EventTarget eventTarget = (EventTarget)(svgDoc.getElementById
("city"));
eventTarget.addEventListener("click", this, true);
</code>
it's possible to click on the graphical element "city" and receive a
org.w3c.dom.events.Event.

I thought it'd be possible to put recursivly each element in a Vector and
then go through the Vector and adds the EventListener:
<code>
private void registerListeners(Vector vector) {
EventTarget eventTarget;
for (int i = 0; i < vector.size(); i++) {
eventTarget = (EventTarget)vector.elementAt(i);
eventTarget.addEventListener("click", this, true);
}
}
</code>,
but nothing happens.

I can't figure out the mistake, maybe there are more simple method...

Thanks, Michael.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top