I have the following hierarchy with Swing:
JFrame
|
+---> several JPanes
one special JPane with a Canvas
|
+------> Many Shapes on the Canvas that are derived from JComponents
I am confused where to put the Mouse event handlers to detect whether one of the shapes has been clicked. All examples I found so far, attach the event handlers to the root JPane, but since I want to process the events on the circles themselves, it feels quite expensive to loop over all shapes, when a click event on a JPanes is detected.
What is the right approach to have "local" events on the Shapes?