Figuring out where a mouse click is under an image
I want to create a JFrame (or JPanel) where the whole area is one big gif (or icon etc) and I want to make some areas of this panel react to mouse clicks and other areas display messages.
There are two ways that I can think of doing this.
The first is that I figure out the x and y coordinates of each area and check to see if each mouse click is within that area.
The second way is to see if I can figure out how to put something like transparent JButtons over the areas that I want to accept mouse clicks (all the areas will be rectangular) and just do what JButtons do normally.
The second way sounds easier but I don't know how to do that.
Does anyone have opinions on which way I should do it?
Thanks

