Animated GIF in JTabbedPane - repaint madness!

Loading and animated GIF into the icon for a JTabbedPAne just works, but it causes the paintComponent method on the main part of the panel to be called repeatedly. Anyway to distinguish between the two areas? The icon repaints automatically but I don't want to have to repaint the rest of the panel unnecessarily.

I've run into the same problem simon, the only way I came over this was to do my own animation for the gif. Bit of a bother really. Anyone have any other solutions?

Similar Messages

  • Animated Gif Repaint

    I knew I was going to end up here eventually, stupid animated gifs.
    First of all, I get weird drawing artifacts on an animated gif on jkd 1.5, I upped this to 1.6 and everything is cool with displaying the gif. It could be because I'm running JBuilder in a XP VM. I don't really care how to fix this, or if its even fixable, I'm just pointing it out.
    I have an animated gif in an imageicon. The program is hangman, and the gif shows a stick figure walking up onto the podium to get hung. I would like to play the gif once, every time the "New Game" button is clicked. I have tried a variety of things to do so, including JLabel1.repaint(); calling the label again, etc, etc. I'll try to post the relevant bits of my code.
    public class HangFrame
        extends JFrame implements ActionListener {
      public HangFrame()
        try {
          jbInit();
        catch (Exception ex) {
          ex.printStackTrace();
      }jbinit calls the placement of all the items.
        jLabel1.setBounds(new Rectangle(19, 57, 550, 400));
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == start) {
          start();
    ....'start' is my name for the button that reads "New Game".
    The start method contains:
    ImageIcon maingif = new ImageIcon( (ClassLoader.getSystemResource(
            "hang1.gif")));
         jLabel1.setIcon(maingif);
    //I've been trying different stuff right here, like repaint.The image displays correctly, and runs once (per the setting I gave it in flash, or thats how java does it).
    I've searched extensively (seems I got lucky by just managing to get it to display once :D). I saw that I might have to flush the image or something like that, but I'm not really sure what that means. I've never had any experience with the graphics and paint component, most of the work we do in class is console and algorithm stuff. I got bored over break and made my hangman into a swing app. I'd appreciate any help.
    Oh, and sorry if this should be in the swing subforum, I figured my issue was too basic for it.
    Edited by: rpk5000 on Dec 31, 2007 8:52 AM

    rpk5000 wrote:
    This is where you're wrong. Dipshits like you post **** like this all the time when it's readily available information that can be searched for WITHOUT >hosing up our forums.Great, give me a link, or even a search term to use on google or these forums. Before you give me search terms, you might want to actually check and make sure the answer is somewhere there...are you out of your freakin mind?!?!?!
    go to google and type "java gif animation"
    you think you're the first person to want to do this?!?!
    moreover, search the forums here
    you think you're the first person to ask for this here?!?!
    You would think "repainting an imageicon animated gif java" would give a page that has the answer on it within the first 10 results but....
    I'm looking for a page that simply says, take your imageicon and call.... (repaint();) or whatever to make it run one more time.Did you even read the API for ImageIcon! It took me 2 seconds to find the information for animating gifs as imageicons.
    Well Java just sucks now doesn't it. Stop using animated gifs and Java since they suck. There, problem solved!I like Java a lot, I'm just saying, in certain instances it seems to fall short.No, YOU fall short. I found the solution in 3 seconds.
    This is a "New to Java" subforum, if you can't handle helping people in a pleasant manner, that shows you respect the other person, what do you think people will think of you and java. If I spent more time on forums like this, and was looking at which language to try, I doubt I would pick java.I don't care what you think of me OR Java. I'm tired of noobs wasting forum resources with this crap. Once I was new to everything, but I went to the library and when the internet came along i learned how to search it!
    Critical thinking people. Don't we teach this in schools any more?!
    When it becomes an Internet joke (http://thedailywtf.com/Articles/plz-email-me-teh-codez.aspx) about how bad the sun forums are, well, you really need to reconsider what you want to do with your life.
    LMAO! You are the daily WTF!
    Edited by: wpafbuser1 on Dec 31, 2007 1:52 PM

  • Exporting flash video made with swift 3d to animated gif help

    I know there is a new grounds link about setting your publishing settings to get animated gifs to work with flash.
    I am using CS4 and when I go to publish the gif works in the html document. But when I export to an animated gif it is still a still picture.
    I have also tried to export to a quicktime file and it's is a still picture there too and distorted.
    Can anyone help me out? Should exporting to png or gif sequence work as well?

    turns out the swift 3d tutorial has you put the animation in a single keyframe within layer one.
    so only one frame is shown or created. there go it stays static
    now if someone could help me wiht resizing a gif for fireworks i would be the happest person

  • Using an Animated GIF/JPEGs Effectively

    I have an animated GIF in an applet with around 200 frames, moving at a speed of 6 frames per second. However, when just drawing it in paint(), it looks extremely messy with the flashing. Then I tried another tack, and exported the gif as 200 jpeg files and used double buffering to draw it in a JPanel with the following code:
    public void load()
         images = new ImageIcon[numImages];
         for (int i=0; i<images.length; i++)
              String num = "" + i;
              if (num.length() == 1)
                   num = "00" + i;
              if (num.length() == 2)
                   num = "0" + i;
              images[i] = new ImageIcon(dir + imageNm + num + ".jpg");
         setSize(getPreferredSize());
         startAnim();
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         if (images[currentImage].getImageLoadStatus() == MediaTracker.COMPLETE)
              images[currentImage].paintIcon(this, g, 0, 0);
              currentImage = (currentImage + 1) % numImages;
    public void startAnim()
         if (animTimer == null)
              currentImage = 0;
              animTimer = new Timer(animDelay, this);
              animTimer.start();
         else if (!animTimer.isRunning())
              animTimer.restart();
    public void actionPerformed(ActionEvent e)
         if (currentImage == numImages-1)
              stopAnim();
         repaint();
    public void stopAnim()
         animTimer.stop();
    }However, the outOfMemory Exception appears after loading approximately the first 50 stills. Any suggestions, besides having to extend the memory usage?

    deltacoder, I tried what you suggested in the code below, to keep the images inside an array of 20 and to rotate them as soon as the image is displayed.
    public void init()
         images = new ImageIcon[20];
         for (int i=0; i<20; i++)
              String num = "" + i;
              if (num.length() == 1)
                   num = "00" + num;
              if (num.length() == 2)
                   num = "0" + num;
              images[i] = new ImageIcon(dir + imageNm + num + ".jpg");
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         if (images[currentImage%20].getImageLoadStatus() == MediaTracker.COMPLETE)
              images[currentImage%20].paintIcon(this, g, 0, 0);
              if (currentImage < (numImages-21))
                   String numStr = "" + (currentImage + 20);
                   if (numStr.length() == 1)
                        numStr = "00" + numStr;
                   if (numStr.length() == 2)
                        numStr = "0" + numStr;
                   images[currentImage%20] = new ImageIcon(dir + imageNm + numStr + ".jpg");
              currentImage++;
    }However, for some reason, it is still laggy. Can you perhaps see why from my code? must41, I am also working on your suggestion. In your thread for loading images, shouldn't there be some sleep time? Otherwise, the thread might get ahead of itself and cause outofmemory exception. And from what I know, whenever garbage collect runs, the code will run laggier than usual no matter what. Perhaps, I should have mentioned earlier, but there is also an AudioClip playing in the background (which does take up memory itself) that I like to match to the images (which i know will match because i made the animation using Flash MX), which is why I can't afford the lag from the garbage collecting.
    Perhaps there is a way to combine both of your suggestions?

  • Load/import images into layers to create animated gif in PE4

    I'm trying to make an animated gif using Photoshop Elements 4.0.
    I have numerous images (photos) that I need to insert into separate frames of one image.
    (photo1, photo2 ..... photo10 - all combined in layers to create the frames of the animated gif)
    I can open each photo separately, copy it, go the the animated gif image, create a new layer, and paste the image into the layer to create a frame in the animated gif.  This is very time consuming.
    Does Elements 4.0 allow for just opening/importing the separate images (photos) into the layers (frames) of the gif direclty?  I remember having software that came with Macromedia Dreamweaver 4.0 in 2000 that made this simple and straight forward.

    We are not the right people to ask.  The Touch forum (for tablet) is at
    Adobe Photoshop Touch for tablet
    There's a long list f video tutorials here, but I can't see anything about animation
    Learn Photoshop Touch | Adobe TV

  • How can I make a transparent animated gif?

    I'm using CS2. I have an animated gif that I want to take the black background out of so that the animated part of it is all that remains.
    Here is a link to the image:
    http://img.photobucket.com/albums/v97/tragicmike/random/Tesseract.gif
    I basically want to remove all of the black background from the image so that the animated tesseract is all that remains. I know how to open the gif to expose the layers using ImaegeReady, then edit them in PhotoShop. But when I made the black areas of each layer transparent (by selecting the RGB channel, inverting the selection, and hitting delete), saved a copy, and tried viewing it, it seems to just display all of the transparent layers constantly instead of cycling through them.
    Can someone please help me figure out how to make an animated gif with a transparent background? If I lose some of the black areas of the animated part (since they seem to get deleted when I remove all of the black background) it's no big deal. I just need to know how to do this so that it plays correctly.
    Thank you!!!
    Mike

    &gt;
    <b>"I have to wonder why the black background was included on every frame of the moving shape."</b>
    <br />
    <br />Well, George...the only reason I can think of is because it's an animated GIF, and GIFs only support one layer.
    <br />
    <br />Whatever application it was created in should have been able to render it out with a transparent BG. But I suppose the creator had his/her reasons for going with the black BG.
    <br />
    <br />(Full disclosure: I ran across
    <s>that same</s> a similar animation back in December, and the version I grabbed only had the black showing through the inside of the tesseract. I opened it in ImageReady and
    <b>
    <i>added</i>
    </b> a black BG so the edges didn't look jaggedy.)
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1FgHXbj4UpXYtUVrbeah7sbqQXDR40" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1FgHXbj4UpXYtUVrbeah7sbqQXDR40_thumb.gif" border="0" />

  • Disabled JMenuItem doesn show animated gif

    Hi there
    I would like to have a popup menu with actions that are enabled after they have finished with some background task taking some time. Basically this works fine for the enabling action on a shown popup. However, adding an animated gif as the icon or disabled icon does not show it in disabled state. In enabled state it works perfect. Please have a try with the sample code. You should see the disabled item for 2 secs and the icon is not showing up. After being enabled, it does. Invoking the menu again shows the animated gif in its last state left, but not moving any more.
    I guess, repaints are not done appropriately in disabled state... Any ideas how to solve that would be highly appreciated :-)
    Actually I used the icon at http://mentalized.net/activity-indicators/indicators/pascal_germroth/indicator.white.gif
    Cheers
    Daniel
    public class Main
      public static void main(String[] args)
        final JFrame frame = new JFrame();
        frame.addMouseListener(new MouseAdapter()
          public void mousePressed(final MouseEvent e)
            final JPopupMenu popup = new JPopupMenu();
            popup.add(new JMenuItem("Open..."));
            popup.add(new JMenuItem("Close"));
            final JMenuItem action = new JMenuItem("Long loading until enabled");
            action.setIcon(new ImageIcon("C:/spinner.gif"));
            action.setDisabledIcon(new ImageIcon("C:/spinner.gif"));
            popup.add(action).setEnabled(false);
            popup.show(e.getComponent(), e.getX(), e.getY());
            SwingUtilities.invokeLater(new Runnable()
              public void run()
                try
                  Thread.sleep(2000);
                  action.setEnabled(true);
                catch (InterruptedException e1)
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300, 200);
        frame.setVisible(true);
    }Edited by: daniel.frey on Apr 22, 2009 7:50 AM

    The problem is that you are causing the EDT to sleep, which means the GUI can't repaint itself. Read the section from the Swing tutorial on Concurrency to understand what is happening.

  • Keynote 3: Transparent Animated GIF Problems

    I've been trying to get an animated GIF with a transparent background to run in Keynote, but it's giving some disastrous results.
    I produce the animation by rendering the frames as PNG (with alpha channel) in MegaPOV 1.2.1. Then I use the convert utility from ImageMagick 6.2.9 to make them into an animated GIF.
    When I drop the animated GIF into Keynote 3.0.2, the first frame shows fine (with transparency and all). But when I animate it, the background goes red (the main color in this particular movie) and some trace of the previous frames stays. It seems like:
    1. Rather than displaying the GIF frame-by-frame, each frame is getting layered onto the previous frames.
    2. Keynote doesn't like the alpha channel for some reason.
    Problem 1 is also present if I open the GIF in Preview (is that supposed to be the correct behavior of an animated GIF?). Problem 2 seems to be Keynote-specific.
    Any suggestions for a work-around on this? The animated GIFs work fine if rendered without the alpha channel, but it'd look so much better with transparency!
    iMac 2GHz Intel Core 2 Duo   Mac OS X (10.4.9)  

    MegaPOV doesn't have a GIF output option. The choices are PNG, Targa, PPM, and hdr (not familiar with that last one). I don't know if PPM even has alpha-capability.
    So in some way, I have to convert PNG to GIF. The tools I have to do this are ImageMagick and Gimp. I tried them both, then viewed the results using several programs. Results are tabulated below -- (1) means that problem 1 from above was apparent (ie, parts of the previous frames were visible under the current frame); (2) means that problem 2 was visible (ie, the transparent parts took on some background color).
    If I didn't know how to change the default white background in the program, I couldn't tell whether problem (2) occurred, since the movie made with Gimp had a white background in Keynote.
    Using ImageMagick 6.2.9 to convert PNG->GIF and animate GIF:
    * viewing with Safari 2.0.4 : (1), can't tell for (2)
    * viewing with Preview 3.0.9 : (1), can't tell for (2)
    * viewing with Firefox 2.0.0.3 : (1)
    * viewing with Keynote 3.0.2 : (1), (2) -- alpha goes red
    Using Gimp 2.2.11 to convert PNG->GIF and animate GIF:
    * viewing with Safari : (1), can't tell for (2)
    * viewing with Preview : (1), can't tell for (2)
    * viewing with Firefox : (1)
    * viewing with Keynote : (1), (2) -- alpha goes white
    I only converted the first few frames using Gimp, since I was doing it by hand.
    All of this makes me wonder whether I'm dreaming the impossible, since problem (1) is universally present. It also makes me pretty sure that problem (2) is Keynote-specific.
    If there are any other tools that will convert/animate GIFs on a modern Mac, I'd love to hear about them. My UNIX-y tools seem to be failing me here. The Mac tools I remember from "back in the day" -- GIFBuilder and GIFConverter -- seem to have been abandoned around the beginning of Mac OS X. GIFBuilder won't even load my files, and GIFConverter still lacks alpha support in PNG.

  • My animated gif keeps pausing in captivate and flash

    Hi guys, thanks for your help.
    I made an animated gif in Photoshop CS4 and inserted it as an animation into captivate 6. The animation works (I played it several times by opening it with internet explorer and safari). But when I open it in Captivate the animation goes black for a split second-several times, before it reappears-several times. It gives it almost a "reloading" or pause look when I play it. The same in flash, but in Adobe Flash CS4 Professional the timeline shows black dots once in a while, as you can see in the screen shot below.
    See those black dots? I will insert a picture of what happens, when the player lands on one of those black dots:
    It's the same animation, but only shows a little. Like I said, it plays fine when I open it with an internet browser, it plays fine when I play it in photoshop, but it just won't work with flash or captivate.
    Any thoughts? Thanks so much!! I really appreciate your help guys!
    Nat

    No problem. Building a simple animation in Flash isn't that bad. You could save each "frame" as an image from PhotoShop and then import these into Flash and place one frame at the time on a keyframe in the flash timeline (press F6 to insert a keyframe).
    If you want your animation to loop then you don't have to do anything as this is the default behavior. If you want it to stop at the last frame you insert a command in ActionScript to stop it. Select the last keyframe and hit F9 and type stop() in the ActionScript window.
    Good luck!
    www.cpguru.com - Adobe Captivate Widgets, Tutorials, Tips and Tricks and much more..

  • Animated Gif to BMP

    *tl;dr- Easy way to take the frames of a GIF and change them to a BMP (there are about 40 frames per Action)
    So- My friend was learning Java to build a game on Android while I would create the graphical resources. It will be a fighting game- so I went ahead and made animations for the moves and all the characters.
    He needed help understanding the language so I thought I would go ahead and teach myself as well.
    I read faster than him- and I got to a point where I find out that graphical resources have to be in BMP (or so the author tells me) and that each frame in gif is a seperate BMP.
    So- is there an *
    Photoshop CS6
    Willing to get on the cloud or something for the other CS programs.

    Yes, Ps CS6 can do that. An animated GIF will be opened as a document with each frame on a separate layer. Then the "Export Layers to Files" script can export a folder of BMPs.

  • Animated GIF Export issues

    I have a simple Flash animation which I'd like to be made
    into a transparent GIF.
    When I do the GIF export, only the first frame of my
    movieclips (which are placed in the main timeline) get rendered. It
    seems like Flash only records the main timeline preview output into
    the GIF file, and does not play movieclip objects. You would expect
    the GIF recording to be of the same preview as when you hit
    ctrl+enter (essentially final playback).
    Because of this, the GIF export is pointless. The only way to
    use it is to have all your animations occur in the main timeline,
    and not within movieclips. It doesn't work for me (and for most
    people?), because I need to easily scale my animations, which is
    doable by just resizing a movieclip.
    Is there a way around this in Flash? Am I missing something?
    I've had to use a 3rd-party tool (Magic SWF2GIF) to do the
    GIF recording.
    My other issue is Flash cannot export transparent GIF's it
    seems. Because of this, I have to rely on more 3rd-party GIF tools,
    most of which are rubbish.
    In the end, I've had to take snap shots of every individual
    frame and edit each frame as individual files in Photoshop to do
    all the cropping and transparency just right. Real pain when you
    are talking 50 frames, and having to do multiple animations.
    Is there a way to export transparent GIF's in Flash?
    Seems kind of dumb that I have all this high-end software and
    loads of tools... and I still have to edit things frame by
    frame.

    Thank you for your reply!
    I check exported GIFs in various browsers and XnView viewer.
    It's definitely not a preview  issue - i have 32Gb of RAM and Nvidia Quadro 4000 GPU on my system.
    I believe the issue is with transparency, because i'm able to export GIFs with solid background just fine
    GIF export dialogue window has 'Transparency' checkbox, so it looks like it should be possible to export an animated GIF with transparent background, but for some reason i'm getting all frames at the same time
    thank you

  • Animated Gif question

    I'm trying to create an animated gif. I made a BG image that I want the video to go on top of. The video is 136 frames (layers). I duplicated the BG image 136 times and pasted the videos 136 layers on top of the BG image.. Here is my problem.. I need to move the video frames (136 of them) onthe background so it lines up better... How do I move them all at once. Meaning if I move the frame on layer 1, the frames will move on EVERY layer. There has to be a way to move them so they all move to the same location at once. There is no way I could move each one separately and get them in the exact same location... I know this isn't the ideal way to do it, but it will work for what I'm wanting to do.. I just want to be able to move the video layers to a new location compared to where they are when I paste them on the BG...
    PLEASE HELP!!!
    Thanks in advance...
    GT
    Edit: Using PS CS4 extended

    well, when I use to use imageready, I would have to duplicated the BG for each frame of the video...
    What would be the best way to do this then,,,
    I have an animated gif that is 136 frames ..
    I want to put it on a BG I  made in PS.... When I copy and paste all the frames (via the animation palette select all) onto the new bG the image is not centered on the BG I made... I want to move each frame to a new location on the BG... How would I go about doing that?
    Sorry if I'm not explaining it clearly... I'm trying..LOL
    Thanks for the reply..>GT

  • Animated Gif with large base image & small animated part.

    Hello guys
    I'm not really sure how to explain that, due to my limited English comprehansion. I will try with images.
    I can easily create animated gif out of multiple layers, given each layer is identical, with small changes accuring over time.
    But I yet to figure out an animated gif, that uses one large image for the base, and only small part of it is animated.
    I always get the animated part working, without the large base applying across all the frames. All it does, is flashes once
    the frame is reached and then moves on to being transparent, showing only the small animated part.
    For example, this is a GIF made with Galaxy S4, of my friend playing with his phone, imported into PS CS6. On the Galaxy,
    after I record the GIF, I can use my finder to touch, mask and freez parts I don't want to move, and leave only small, animated bit.
    When I import it to PS, it shows one layer with full image, and bunch of frames with the animation part only.
    http://i.imgur.com/UAiopQA.jpg
    http://i.imgur.com/7XOGGV6.jpg
    Problem is, once the image is open with PS, I'm not able to export it to keep it working in the same manner. Given the Samsung's
    gifs are 8 to 10mb, it's hard to edit it, to make it more size friendly.
    The gif clearly works the way I describe, so there is a setting or method I don't know about.
    If PS is not best tool for editing GIF, what other apps would you recommand I use for it?
    Thank you for the taking the time to read
    best regards
    Monica

    This has been an ongoing issue for me since I switched from Powerpoint to Keynote. Most of the animated gifs with transparent backgrounds that I used with Powerpoint are no longer transparent in Keynote. You may want to search for those earlier threads on this topic...
    To summarize: I've had to open up my animated gifs in After Effects and use the Color Key effect to restore transparency, with mixed success.
    Good luck!

  • Animated gif import

    Is there any other way to import an animated gif that import it frame by frame?

    Not in iMovie.
    GIF files are made up of "frames" and each frame may not contain all of the data from the previous or next frame to complete an image file.
    I use GraphicConverter to export to other formats.
    QuickTime Pro can also open and export GIF formats.

  • Animated .GIF Issue Need Help

    I made an animated gif with a transparent background, saved it for the web with the best quality settings I know of, and the image gets this weird white outline around it. Here's what it looks like on grey background so you can actually see the issue I'm having: http://imgur.com/ujKBJDu
    at first I thought it was an anti alias issue with my crappy laptop, but then when I exported it on a high end gaming pc it looked exactly the same. Anyway I need to export this and not end up with this issue so any help is appreciated.

    When it comes to gif, there is no anti-aliasing. As the transparency has only one shade of grey. The white line is residual from a white background.

Maybe you are looking for