I'm trying to implement a mouse click event for an image (basically a tile on a map) on a JPanel. I'm just not able to figure out how to go about it. I have a Main class that extends JPanel. I'm retrieving tiles from a tile server and displaying them in the paintComponent() method of the Main class based on the specific zoom level. I use tiny locator images to represent a specific monument or a building in a city in the same paintComponent() method. They are placed on top of these tiles based on corresponding latitude and longitude.
When I click on these locator images, I must be able to add an event MouseClick() to the locator image. Now what I've read so far is we cannot add an event handler to images. It can only be added to native components of swing. How do I go about adding the events to the tiny locator images when I have not represented it using JLabel or even surrounding the image say with a rectangle?