Mouse Picking in AWT

Hello,



I have alot of trouble with Mouse Picking in an AWT application, using a canvas object.



I have alot of boxes, and a camera that looks from top down to the boxes. The whole boxes can be rotated by user input.



My problem now is that Mouse picking doesnt work as expected. First problem was that I cant use getHotspotPosition, cause its no LWJGL, but AWT. Instead I tried getAbsolutePositon from mouseInput. This gives me some trouble. If I pick a box somewhere on the left half, the box besides it gets picked.

I think thats because of the height of the mouse cursor, so I added 32 to the absolute position. But that doesnt help. Its better but not good yet. Especially if I rotate the whole boxes about 180

I suddenly found the problem after days of trying:



The canvas object was in the center of a BorderLayout. So, when resizing the window, the coordinates went wrong. Putting it into a panel works like a charm.





DKT