Q:

Java: Playing a GIF once

So im a relatively new to Java and I'm currently trying to make a turn based rpg. I was able to add idle animations as JLabels and when i click the "attack" button i want the attack.gif to play once and return to the idle.gif. Any way I could set that up?
example of the code:
    if(source == menu.attack) {
        //disabling the attack button for the duration of the animation
        menu.attack.setEnabled(false);

        //setting the idle animation to invisible
        menu.idle.setVisible(false);
        //setting the attack animation to visible
        menu.attack.setVisible(true);

        player.attack(enemy, menu);
        update(player, enemy, menu);
        }

A:

Use a different Thread, to control the animation state;
A suggestion:
public void doAttackAnimation(){
   new Thread(()-> {
         setIcon("Your Attack Animation");
         sleep(durationOfAnimation);
         setIcon("default Animation");
      }).start();
}

