Java graphics events not occurring in the order I expect them to
问题 So I'm making a graphical card game. Each card is a JPanel with a button and two images associated with it. I have a flip method, which is the first thing I call in my action listener when a card is clicked on. public void flip() { if(b1.getIcon() == card2) b1.setIcon(card1); else b1.setIcon(card2); revalidate(); repaint(); } However, for some reason the card doesnt flip (meaning the icons don't change) until some point after I call this method. For example, when I put a Thread.sleep after I