How do I add animated .gif files to a JFrame?

Hi, I'm making an underwater scene in java for my degree assignment. I have a JFrame with an underwater background and a bunch of .gif fish moving around inside, but they should be animated and they're not. They animate outside of java. How can I make the .gif files animate?

Hi, I'm making an underwater scene in java for my
degree assignment. I have a JFrame with an underwater
background and a bunch of .gif fish moving around
inside, but they should be animated and they're not.
They animate outside of java. How can I make the .gif
files animate?A simple example:
/* save as AnimeGif.java */
import javax.swing.*;
import java.awt.*;
import java.util.*;
class AnimGifPanel extends JPanel{
  Image[] imgs;
  int w, h;
  Random rand;
  public AnimGifPanel(Image[] ims, int wid, int hei){
    imgs = ims;
    w = wid;
    h = hei;
    setPreferredSize(new Dimension(w, h));
    setBackground(Color.cyan);
    rand = new Random();
  public void paintComponent(Graphics g){
    super.paintComponent(g);
    for (int i = 0; i < imgs.length; ++i){
      g.drawImage(imgs, rand.nextInt(w), rand.nextInt(h), this);
public class AnimeGif{
public static void main(String[] args){
String filename = "fish.gif"; // an animated gif
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = frame.getContentPane();
Image[] ia = new Image[5];
for (int i = 0; i < ia.length; ++i){
ImageIcon ic = new ImageIcon(filename);
ia[i] = ic.getImage();
AnimGifPanel agp = new AnimGifPanel(ia, 500, 400);
con.add(agp, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);

Similar Messages

  • How to edit a Animated Gif file and convert to SWF

    I am using the creative cloud with fireworks. I chose the free trial with buying in mind if I saw it work properly. I simply want to upload an animated GIF file and then download it as a SWF file. I saw someone on youtube do this and it's not that if I get on the correct page I would not know how to do that but I just cannot find how to get the GIF into the software to edit. It has just simply put them in the creative cloud folder which can open them on IE> How do i make it available to edit and convert to SWF please? Thanks in advance.

    You will likely get better program help in a program forum
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • I finished making an animated .gif image in FireWorks. My question is, how do I convert it into video so that when I edit video, that every video editing program recognizes it? Long story short, How do I convert animated .gif files into video formats?

    I worked in Adobe FireWorks to make the animated .gif. What program do I use to convert the file from .gif to any video format: .mp4, .m4v, .avi, .wmv, etc. I want to convert it into video format, so that QuickTime Player plays the video, I can insert it into iMovie '11 and edit, and also insert it into Final Cut Pro X and edit video.

    Thanks for getting back with me so promptly.  It has taken me this time to connect with the proper people to find out the information you requested.
    The camera used to film the class was a Panasonic AG-HMC40P, owned by a local cable TV station; they use Kodak video encoding software, and a SD card was used to store the video.   The file extension is .mts, and the mime file is MPEG 2 transport.  He said I probably need an AVCHD converter, and the Mac app store lists 8 of those options, 4 free and 4 for up to $9.99.  He said I'll also need a converter for later plans of posting on YouTube or on the website, and while some of those in the app store might work for the later needs, he knows one app called "Compressor" that would work for the uploading later.  He also suggested I could try renaming the .mts file to .MP2T, but he wasn't sure that would work.
    They don't work with Macs at the studio, but I had thought I could have some lessons there in editing, and apply what I learned to my iMac and iMovie.
    First, though, I have to be able to see it and review it!
    Thanks again!

  • How can I add animated gifs to a slideshow?

    I want to  put some animations into my slideshows.
    I want to add in animated gifs. I can do this with Videowave (Roxio). Can I do the same thing with elements 8?

    Double click on the photo in the thumbnail tray at the top to get into the edit mode.  There Control (right) - click on the image and select Duplicate from the contextual menu.
    Go back to the slideshow mode and there will be two copies of the photo in the tray which you can place wherever you want.
    OT

  • How to open animated .GIF files in Photoshop CS3 and newer

    Q: Since ImageReady is long gone from Photoshop, how can I open animated GIF files in Photoshop CS3 and newer?
    A: File -> import-> video to layers.
    In the dialogue box type "*.*" to show all file types.
    Select your GIF file and which frames to import.
    They will now be available in your animation palette.

    Zeno
    curt y, sorry for the late reply, I tried that but I doesn't work. I have to choose at least two files in the Load Layers window in order for the OK button to be available and then some action script uses the different files to make layers and merges them but not from the frames of the gif file. I can undo through the script to see what it did but it never accessed the frames of the gif file, just the first frame. Choosing "make frames from layers" in the animation palette only puts the original files into layers - that is only the first frame of the gif file.
    I guess I'm out of luck with the 64  bit version of Photoshop as Zeno suggested :-(
    What program would you people suggest for opening each frame from gif files?

  • How to remove background of a animated GIF file?

    i have revoling rings animated gif file, i want remove its blackgroung and want add plain white backgroung. how to do that? i use PS cs 5

    Remove the background from each frame's layer so their background is transparent. Then add a new bottom layer which is the replacment background and set it to be visible in all frames of the animation. Then save for web. Why can't you show the animation is its content agenst the rules here. Use the background removal method the works best for each frame.

  • Is it possible and how to open animated gif files in Photoshop CS4

    I made a Google search and I found tips that Photoshop can open frames from animated gif files by using File->Import->Video Frames to Layers. But this menu is missing from Photoshop CS4 on the computer I'm using it. Searching this forum for "Import animated gif" didn't return any result. Any ideas?

    Zeno
    curt y, sorry for the late reply, I tried that but I doesn't work. I have to choose at least two files in the Load Layers window in order for the OK button to be available and then some action script uses the different files to make layers and merges them but not from the frames of the gif file. I can undo through the script to see what it did but it never accessed the frames of the gif file, just the first frame. Choosing "make frames from layers" in the animation palette only puts the original files into layers - that is only the first frame of the gif file.
    I guess I'm out of luck with the 64  bit version of Photoshop as Zeno suggested :-(
    What program would you people suggest for opening each frame from gif files?

  • Editing an animated gif file

    Hi experts,
    I have an animated gif file that works in my Dreamweaver website.  However, I edited the gif file in Photoshop, changing the image and canvas sizes.  When I save it (as a gif), only the top layer is retained, and it's no longer an animation.  How can I save the edited file and keep it as an animation that will work on my web page?
    Many thanks for hints
    Richard

    What version of PS are you running? In CS4, 5 and 5.5 (not sure on the others) you simply just open the .gif. It should be in layers - one layer for each frame. You will then need to open the animation panel before making any modifications. If you don't, it will change each frame to the current.
    You can't use save as. You need to use save as web or devices then make sure it's a gif and ensure the frames indicator says more than 1. You can then use the play/forward buttons to make sure it looks as you expect.

  • Can Premiere Elements be used on an animated gif file?

    I am considering purchasing Premiere Elements but I need to know if one can use it to add effects to an animated gif file.
    For example, in Photoshop Elements one can add certain effects to a gif image, such as giving it certain textures or filters.
    Can one do the same kind of thing in Premiere Elements and if so can it be done to an animated gif file?
    Maybe a better way to ask this question is:  can you import an animated gif file into Premiere Elements and then manipulate it?  Run filters, etc.
    Thanks for your help.

    If you load your GIF into Premiere Elements 10, edit it, then share to an AVI file, you can then import the AVI file into GIF Movie Gear by Gamani, which will then create an animated GIF. I learned about this utility from a Microsoft tutorial on creating icons for Windows XP.
    http://www.gamani.com/product_icon.htm
    If you use Firefox and get redirected, try using Internet Explorer instead.
    After the trial period is over, it's $29.95US for 4 licences.
    When you share to an AVI file, you will want to select the Microsoft AVI item from the list, then click the advanced button to open up the dialog where you will need to select a codec and enter the frame size and frame rate. The codec will have to be one that GIF Movie Gear likes, so there may be some trial and error needed to get a good codec. I shared to an AVI after picking Xvid for the codec, which GIF Movie Gear imported.

  • Animated GIF file Creation from no of JPEG files

    Does anybody know the program to convert a many JPEG files to a single animated gif file.

    Oh? And when did you ever say that? Perhaps you should provide clear questions and requirements.
    [http://www.google.com/search?q=animated+gif+java|http://www.google.com/search?q=animated+gif+java]
    Still, learn how to use Google.

  • Activation of links to embedded ".kmz" and "Animated GIF" files.

    I recently upgraded from Adobe Acrobat Pro X to Adobe Acrobat  Pro XI and noticed a slight difference on how documents linked in an Adobe Acrobat File are activated for display.
    I have placed files I want to display in my Adobe Acrobat file as file attachments.  I then link to those files, so that the user can click on an icon area within the document and open the file in a new window. 
    After a little effort, I was able to make the correct links to .pdf file attachments, but ran into problems linking to and displaying files that utilize external applications to view the file.  If I was able to convert this file to a .pdf file, I could open it with no problem.
    However, I am having trouble linking the following file types for display from file attachments already embedded in the Adobe Acrobat document file.
    They are...Portable Network Graphic (PNG), Animated Graphic Interchange Format (GIF), and Keyhole Mark-up Language - Zipped (.KMZ)  and Microsoft Word (PPT) files.
    The .pdf file was originally convered from a Microsoft Word file in which all of the links worked fine.
    I thought I had the problem solved in Adobe Acrobat Pro X, but cannot seem to open the same files iin Adobe Acrobat Pro XI.
    Would appreciate some guidance.

    Thank you for your offer, I do appreciae it.  But I think the better question to ask at this point is :  What is the last version of Photoshop Elements that supports editing animated gif files.  This is too important to me to lose this ability and after checking further I see CS4 is out of my price and needed features range. I would rather hang on to my old laptop to manipulate photos than lose the ability to edit my .gif files.
    Can anybody help with this question?

  • Problems syncing animated gif files on website

    I am running Photoshop Elements 8 and have createdd a series of 7 animated gif files.  Within each of the 7 files consist of 4 layers(photos) with 5 second intervals in between each layer/photo.  Each of the 7 animated gif files have been uploaded to the home page of my website, all 7 animated gif files are set to 5 second intervals and also loop.  The problem occurs when either reloading or returning back to the home page, which causes the animated gif files to go out of sync, making it appear that each one of the 7 files are starting it's sequence at a different time.  My question is, how can I fix this issue?  I want all 7 animated gifs to start at exactly the same time, any suggestions?
    Thanks!

    Welcome to our community
    I'm not 100% sure on this but I believe you will need to convert the GIF to a SWF and insert it that way in order to preserve the animation.
    Click here to see a list of converters
    Cheers... Rick

  • Importing animated gif files

    Hello,
    I have some animated gif files that i would like to import into framemaker.
    The problem is that these animated gif does not activate. Is Framemaker compatible with animated gif's?
    Out of this framemaker file we would like to extract a pdf and a microsoft html help file (via e-publisher).
    How do i keep these gif files animated in Framemaker & pdf?
    We are working with Framemaker 8.0 on a windows vista operating system.
    PDF = adobe acrobat 9 pro.
    Bjorn

    If you are using FrameMaker and WWeP you can certainly use a reference to the animated GIF and pull the animated source into your HTML help from WWeP. Check a WWeP forum on doing that.
    Also, PDF now supports Flash. Have you tried using Flash animations?
    HTH,
    Sean

  • Animated .gif files in Captivate - why doesn't it work?

    OS:                         XP
    Captivate Version:      3
    I was e-mailed an animated .gif that I want to use in a project I'm working on.
    I saved the .gif to a drive.  I then clicked Insert - Animation and selected it.  I received a message stating This is not an animated GIF file or file in use.  If I click Insert - Image, it brings in the image but the file is not animated.
    Just for testing purposes, I moved the .gif file by itself on to the web server.  When I access it through Internet Explorer on the web server, it works.
    How do I get the file to animate in Captivate?
    Your help is appreciated.  Thanks.

    I wasn't able to open your GIF animation in Photoshop and nothing appeared in Captivate when I inserted it -- the same experience that you had. I tried an experiment with a very simple GIF animation that I created from scratch in Photoshop CS4. When I tried to insert this simple animation into Captivate 4, a message appeared that Captivate was converting. It never finished converting and eventually hung Captivate and had to force it to quit.
    Since Lilybiri is able to insert Photoshop animated GIFs into Captivate without any problems, it may be that there are some version incompatibilities. It would be interesting to know which versions of Photoshop and Captivate Lilybiri is using and which versions you are using. It would also be interesting to know if Lilybiri is using transparency in the GIF, and which settings are being used when saving the GIF.

  • Animated GIF files in SWF

    I have an FLA file that is utilizing numerous animated GIF
    files the files themselves are also rather large. I was hoping that
    when rendering the SWF file it would simply render to the
    resolution stated and the individual components within the FLA
    should not matter. For example, a SWF file of 100 X 100 playing for
    10 Seconds would be half the size of the same thing running for 20
    seconds. And the number of GIFs or other elements within the FLA
    should not matter. This is obviously not the case... however I
    would like to know how I can effectively integrate animated GIF
    files without hugely impacting SWF file size.
    Thanks for you time :)

    If you are web deployed you can put an animated gif as the image to an iconic button.
    Image items cannot display animated gifs.
    Anything else you can do through a JavaBean if you need to.

Maybe you are looking for

  • How to change the colors for Exceptions

    Can someone tell me how I can change the default colors that assigned to the Exceptions? Thanks. Ryan

  • Is OEM 10.2.0.5 and OIM 10.1.4.2 certified with SOA 11g

    Hi, Can you tell me whether OEM 10.2.0.5 and OIM 10.1.4.2 is certified with SOA 11.1.1.x, if not do we need to install/upgrade OEM and OIM to 11.1.1.x Please refer me some Metalink Note id's if you have.... Cheers, Patel

  • Testing the connectivity between Integration Directory&  Integration Reposi

    Hi Experts, I am verifying  the configured PI7.0 server,but i am not able to fine the Integration scenarios at the stage :         (Testing the connectivity between Integration Directory and          Integration Repositor) In Integration Directory Co

  • Advanced search in NLS environment

    Customer environment: - 8.1.7.1 and iAS 1.0.2.2 with portal created a number of Portal Content Area's with default language Danish with online translation to english. Uploaded a number of document - all stores 2 types (Danish and English)with use of

  • [solved] VSFTPD + Virtual Users + different home directories

    Hi All,    I've been trying to get VSFTPD setup to allow ftp access to some of my clients to access their web files. I've got VSFTPD up and running via the Wiki, but my virtual users can't log in. The only thing that I didn't do from the wiki was the