I'm building a memory match game and in the ActionListener I want to implement an animated gif before uncovering a block, but the gif never shows, I assume it resets; how do i fix this?
for(int i = 0; i< buttonNum; i++)
{
if(e.getSource() == button[i])
{
try
{
URL blockIcon = this.getClass().getClassLoader().getResource(block[i].toString());
//sets it to the gif
button[i].setIcon(uncoverBlock);
Thread.sleep(5000);
button[i].setIcon(new ImageIcon(blockIcon));
System.out.println("Block: " + block[i]);
currentIndex = i;
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
}
}