Re: How do I get a MouseEvent for each multiple overlapping JComponent?
Posted By:
Alex_Peter
Posted On:
Wednesday, October 20, 2010 02:22 PM
OK, I found out how to do this. I needed to override the contains() method. This is the method called when it is trying to figure out which component to give the event to. The default implementation is to use the bounding box, which covers way too much real estate for a diagonal line. I used the Graphics2D.hit() method to calculate if the event position is within a few pixels of a line.