Does anybody of You know a method to detect, which card on the board was clicked?
I got a class drawing multiple card objects on a JPanel
.
Now I've implemented a MouseAdapter
. On a mouse click it should check whether a card was clicked or not. Additionally it should tell me which object was clicked.
Any theoretical ideas, procedures or methods how to achieve this?
Card card = new Card();
public void paint(Graphics g) {
g.drawImage(card.getImage(), card.getX(), card.getY(), null);
}