How to use the repaint method <p>I am trying to use the repaint method in the following code to update the screen after user input. The game is a card game where the user has to click on two cards to reveal their pictures. If the pictures match the cards remain visible however if the pictures don't match the cards flip over to hide the pictures once again.</p> <p>The first card becomes visible after clicking it, however when the second card is selected either both cards become visible if a matching picture is selected or the first card just flips over without the second picture being revealed.</p> <p>Thanks for your help.</p> <pre><code>addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { int row = e.getX() / (Card.SIZE*2); int col = e.getY() / (Card.SIZE*3); //OPEN means the picture is visible if(cards[row][col].getState() == Card.CLOSED) cards[row][col].setState(OPEN); repaint(); compareCards(row,col); } }); } public void compareCards(int row, int col){ if(clickNum == 1){ r1 = row; c1 = col; clickNum++; } else if(clickNum == 2){ r2 = row; c2 = col; //The OR accounts for clicking twice on the same tile if(cards[r1][c1].getNum() != cards[r2][c2].getNum() || (r1 == r2 &amp;&amp; c1 == c2)){ cards[r1][c1].setState(CLOSED); cards[r2][c2].setState(CLOSED); } clickNum = 1; } } </code></pre>