How do you display an animated GIF in a Java application?
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.
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.
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); }
check it out:
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With