title: Java - How can I pause code without pausing a GIF animation in my GUI?
body: <p>Currently I have a start menu for a game with a button which transform my menu background image from a PNG into a GIF after a button press. Now, I want my code to wait until the GIF animation is over. After that, it should continue normally (by opening a new JFrame with the actual game).</p>
  
  <p>I've read some stuff about a swing timer, although I'm unsure of how to implement this as I am a Java beginner.</p>
  
  <pre><code>private ImageIcon a = new ImageIcon("a.png");
  private ImageIcon b = new ImageIcon("b.gif");
  
  class AddInterestListener implements ActionListener {
      public void actionPerformed(ActionEvent event) {
          bgLabel.setIcon(b); //replace PNG with GIF
  
          //This here is where I want my delay to happen without freezing the GUI 
  
          JFrame game = new JFrame(); //Actual game frame starting etc.
      }
  }
  </code></pre>
  
  <p>Any suggestions?</p>