Results 1 to 4 of 4
  1. #1
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default Animation with Animated GIF

    I need to do an animation, I am using an Image object to load an animated GIF. Is there any way to run all the frames which this GIF contains using the Image Object?. I donýt want to extract each image from the gif and then copy them into a jpg format, and then have to make a loop to animate the set of JPG images... it is possible, only load the GIF, and with some java class, animate the gif?

  2. #2
    levent Guest

    Default

    Animated GIFs are supported by Java. Try following code to test the functionality:

    Java Code:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
     
    public class Anima {
        public static void main(String[] args) throws MalformedURLException {
    
            URL url = new URL("<URL to your 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);
        }
    }

  3. #3
    nuntemon is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default Re:Animation with Animated GIF

    I also have this same question. Is it necessary to add the ImageIcon directly to the JFrame? In the program I am writing, the JFrame is loaded in another class and then the class containing the gif is added to that JFrame.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,300
    Rep Power
    20

    Default

    It's not the same question. The original question was about Java's support for animated GIFs.

    Start a new thread and ask the question that's bothering you. This one's closed.

    db

Similar Threads

  1. Animation Delay - Thread problem
    By wererabit in forum Advanced Java
    Replies: 3
    Last Post: 04-10-2009, 10:35 PM
  2. Text Animation
    By rossomandop@acm.org in forum AWT / Swing
    Replies: 4
    Last Post: 05-30-2008, 03:34 AM
  3. GridLayout with animation?
    By tojas in forum AWT / Swing
    Replies: 3
    Last Post: 11-12-2007, 10:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •