title: How to display cards in a Card Game in Java and have them clickable for selection?
body: <p>I am programming a game of cards in Java, and everything is going well, but I have come up with a problem regarding the user interface. There are 4 players (1 Human 3 AI) and 54 cards. I want to have each player's cards drawn into 4 directions on the screen (UP LEFT DOWN RIGHT) and basically have a <code>MouseListener</code> for human's cards ONLY in order to select a card before playing move (have the card move up a little bit so you know it has been selected) while the other players' cards have their backside drawn and don't need any Listener. I am doing absolute positioning and cards should show up like this: <a href="https://i.stack.imgur.com/xAaad.png" rel="nofollow noreferrer">Image</a></p>
  
  <p>Currently I am extending a <code>JComponent</code> and testing drawings into the paintComponent method of it. As cards are placed and drawn on top of another, working with coordinates is impossible for me to imagine, and also since I have a class <code>Card</code> for cards, can't have the <code>Card</code> instance and the drawn image connected. A thought is to use <code>JLabel</code> for each human cards, add an <code>ImageIcon</code> to it as for card representation, and add a <code>MouseListener</code> for each label so mouse clicking is easily determined. But the problem is how to have them drawn and updated on each player move as it would automatically be done for the other players cards that are just drawn as images inside <code>paintComponent</code>. I did try to create and add JLabels to the component inside the <code>paintComponent</code> method but I've seen it is totally not recommended to do.
  Do you have any suggestion on what idea should I follow?</p>
  
  <p>Thank you and regards</p>