Reputation: 11
The gif plays after entering the frame but how to make it stop automatically after it finished playing once (something like a video) ? I want it to stop at the last frame of the gif not completely close the frame after it has been played.
Upvotes: 0
Views: 172
Reputation: 111
use JFrame.EXIT_ON_CLOSE
URL img = this.getClass().getResource("src/image.gif");
Icon icon = new ImageIcon(img);
JLabel gif = new JLabel(icon);
JFrame frame = new JFrame("gif");
frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Upvotes: 1