Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show animated GIF

How do you display an animated GIF in a Java application?

like image 769
SamSol Avatar asked May 29 '10 13:05

SamSol


People also ask

Why dont GIFs play when I click on them?

To play animated GIF files, you must open the files in the Preview/Properties window. To do this, select the animated GIF file, and then on the View menu, click Preview/Properties. If the GIF does not play, try re-saving the animated GIF in the collection in which you want to put it.

How do I see a GIF?

For Android Nougat: Tap the Smiley button, then tap the GIF button. You'll get an option for stickers or GIFs to browse. Or, to find a specific GIF, tap the search button.


2 Answers

Using Swing you could simply use a JLabel:

public static void main(String[] args) throws MalformedURLException {     URL url = new URL("<url_to_animated_gif>");     Icon icon = new ImageIcon(url);     JLabel label = new JLabel(icon);       JFrame f = new JFrame("Animation");     f.getContentPane().add(label);     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     f.pack();     f.setLocationRelativeTo(null);     f.setVisible(true); } 
like image 143
stacker Avatar answered Oct 07 '22 01:10

stacker


check it out:

http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource

like image 32
Inv3r53 Avatar answered Oct 07 '22 01:10

Inv3r53