0
ImageIcon v = new ImageIcon(getClass().getResource("/Sample1/Image1.gif"));
v.getImage().flush();
jLabel1.setIcon(v);
JLabel2.setText("Sample");

How to finish the animation first before changing the text of jLabel2?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Square Ponge
  • 702
  • 2
  • 10
  • 26

1 Answers1

1

Assuming that Image1.gif is an animated GIF, I see two approaches:

  • Extract the images from the GIF, as shown here, and display them in a single sequence.

  • Play the GIF for a fixed period, then set the label's icon to one constructed from a BufferedImage copy of the GIF, as shown here.

In either case use javax.Swing.Timer as required for timing

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045