"But can i put a mouse listener on an Image??"
No, or at least, not in the context you are thinking.
You have a couple of choices depending on what you want to achieve.
The basic requirement though, is you are going to need to know exactly where on the image each click point is. This is best achieved by using an image editing program to map out the "hot spots" and then code these into your program
You could...
Use a JLabel
to render the board image and attach a MouseListener
to it.
The problem I would have with this is trying to figure out how to update the image with the player markers.
You could...
Use a JPanel
and override it's paintComponent
to render the image and player moves/markers.
You would then add a MouseListener
to it and monitor the mouse clicks from there.
Regardless of which method you used, I would probably create a List
of Rectangle
s which represented the hot spots the user can click. Each time mousePressed
is called, I would walk this list and use Rectangle#contains(Point)
, passing the mouse click point, to determine which hot spot was clicked.
You would then to to compare this with the game model to determine if it's a valid move or not and take appropriate action as required.
Take a look at How to write a Mouse Listener and Performing custom painting for more details