JLabel + Animated GIF: replacing the image

Hi, folks.
I've run into what looks like an interesting glitch, not necessarily functionality-wise but purely cosmetic.
I have a JLabel which needs to be switched between a static image and an animated image at different times of execution. I'm doing this more or less like this:
    private JLabel label = new JLabel();
    private ImageIcon inactiveIcon;
    private ImageIcon activeIcon;
    public MyClass()
        inactiveIcon = Utils.loadIcon(...);
        activeIcon = Utils.loadIcon(...);
        setActive(false);
    public void setActive(boolean active)
        label.setIcon(active ? activeIcon : inactiveIcon);
    }It starts up fine and shows the inactive image, which is not animated.
However, calling setActive(true) seems to cause a flash of grey before showing any animation. The interesting thing is at this point, the image should be completely loaded, so nothing should be blank for any period of time. The other interesting thing is that calling setActive(false) does not cause the flash of grey.
I've checked the image to make sure all the frames are present and that none are blank.
I've tried doing this a number of different ways, by Icon.setImage(Image), also by using two labels and setVisible(boolean).
Has anyone else seen this before? The particular thing which worries me is there isn't a grey flash going the other way. Otherwise I wouldn't think a workaround existed. :-)

Update. I changed the code to this:
label = new JLabel() {
public void update(Graphics g) {
paint(g);
public void paint(Graphics g) {
paintComponent(g);
protected void paintComponent(Graphics g) {
ImageIcon icon = (ImageIcon) getIcon();
icon.paintIcon(this, g, 0, 0);
};It still greys out. :-/
I tried label.setUI(new LabelUI() { ... }) with a
custom paint method also, and it didn't draw anything
at all, for either label.I'm not sure if you accounted for this but the paint method in the UI is different then the 'public void paintComponent(Graphics g)' method and paint (Graphics g) method in components. The method is 'public void paint(Graphics g, JComponent c)'. Overwriting 'public void paint (Graphics g)' in a UI, is like defining a new method alltogether.
Did you also make sure to avoid calling 'super.paintComponent()' when overwriting your 'paintComponent(...)' methods? If you did call it, you aren't preventing drawing of previous shapes. This worked for me when I had to do something similar.
You could also try to draw your icon in your UI, if you haven't done so already.
Regards,
Devyn

Similar Messages

  • Animated gif not moving, image.animation_mode already set to Normal

    ''dupe of - https://support.mozilla.org/en-US/questions/932846 - locking''
    With image.animation_mode already set to Normal, animated gif are not moving, it seems only the first frame is downloaded. I tried downloading the image, it also seems that only the first frame is downloaded. Then I disabled all extensions, the problem persists. Then I use a whole new profile, there seems to be no problem.
    The question is, is there another hidden settings in firefox which cause this trouble? I do not want to start a new profile just because of this. (It also happens in Firefox version 13)

    Do you see the animation if you check the image in Tools > Page Info > Media or open the image directly in a tab?
    Some security software (firewall) can block animated images and send a normal image instead, so can try to check the advanced settings for Firefox in the firewall if the problem isn't in Firefox.

  • Problem with animated gif when direct image sharing over iChat

    Im having an issue that an animated gif isnt displaying animated when I drag and drop it into an instant message window with a buddy. I drag it from Firefox animated into the chat window but its doesnt get animated. I can see his gifs are animated when he drags and drops it from Safari into the chat window. Does the internet browser make a difference, or is there an option I haven't turned on. I tried searching through the preferences and haven't got a clue to what's stopping my gifs from being animated during direct instant message session.
    Im using the latest iChat 5.0.3(745).

    Hi,
    Welcome to the    Discussions
    If you drag the pic to the Desktop (Download) and then drag to the Browser does it display as Animated then ?
    9:03 PM Sunday; December 12, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • Viewing animated GIFs in the Finder and Preview

    I was wondering why my animated gif images do not play while I view them in the preview in the Finder or Preview. I know it plays when I view gifs in Explorer and was wondering why doesn't the Finder/Preview.
    I would really like to be able to view the animated gifs without having to open either Safari or Fire Fox to view them.
    Thanks

    Welcome to Discussions.
    Apparently Preview lost that functionality a few versions ago. And Quicklook also doesn't seem to do it. Someone said that Pathfinder plays them, http://www.cocoatech.com.
    If you don't want to use a "big" program like Safari or Quicktime, then your best bet is to use a quick and easy image viewer like Xee http://wakaba.c3.cx/s/apps/xee.html.
    Set it as default application by selecting a gif file, press cmd-I. Choose Xee under Open with and click Change all.
    /p

  • Possible to Use Animated GIF as Rollover Image?

    Before I spend a lot of time on development...does anyone
    know if it's possible to use an animated GIF as a rollover image in
    Captivate? I'm developing an e-Learning course for a
    Sarbannes-Oxley application, and I want to be able to hover over an
    object, then have a rollover graphic describe the hover target in
    more detail...the catch being that I want the description to look
    like a scrolling stock ticker.
    I'm sure Flash is probably the ideal development environment
    for this idea, but that project is way beyond my Flash skills at
    this point...
    Thanks!

    I know you can load and display a PNG image just the way you do for a GIF/JPEG one :
    ImageIcon myIcon = new ImageIcon("my_icon.png");but I don't think many others formats are recognized by j2se... you can simply try to load a BMP file to find out.

  • Animated GIFs on the web toolbar

    Hello,
    i understand that while deploying forms on the web, the toolbar
    uses gifs format files instead of icon file.
    if it takes gifs, i want to know whether it takes animated gifs,
    has anyone worked on this problem. i hope these is possible. i
    am not getting the right start, can any one you help
    thanks
    Vishnu Vadla
    null

    Matthew Kelton a écrit:
    This worked for me.  You did remember to register the OCX, correct?
    One problem I see is that it doesn't autosize and doesn't tell you what the size of the image is, so unless you know the size prior, you're goign to have to get the image attributes elsewhere.
    Message Edited by Matthew Kelton on 11-04-2007 01:44 AM
    Yes, I did (although not immediately... )
    How did you get the "AnimatedGif" automation refnum ?
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Import animated GIF on the fly

    All the answers I've seen for this one are old so I'm hoping
    it has changed. If not ... GET WITH IT ADOBE! :)
    Can I load an animated GIF into a SWF on the fly (loadMovie)
    and get it to be animated? I know it seems to load just the first
    frame in but is there anyway of programming or anything in AS to
    make it put each frame into a Flash Frame?

    Dinghus wrote:
    > All the answers I've seen for this one are old so I'm
    hoping it has changed. If
    > not ... GET WITH IT ADOBE! :)
    >
    > Can I load an animated GIF into a SWF on the fly
    (loadMovie) and get it to be
    > animated?
    no you can't
    Best Regards
    Urami
    Beauty is in the eye of the beer holder...
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Animation - when-mouse-move/enter or inserting an animated gif into the form

    expecting some animation on oracle forms, eg. say if i move my mouse into the command button, it could change color(fr black to red). any idea? thank u.

    In client server you can use the when-mouse-enter trigger to do that.
    On the web you can use PJC like the sample "Browse RolloverButton PJC" you have on the sample code section of forms on otn.
    On the web you can also embed animated gifs onto buttons as labels.

  • Replacing the Imaging Kernel

    I have the most recent imaging CD, but it still does not work with quite a
    few systems on our campus. I am aware that I can compile in drivers, but
    have run into snags there - so for all intents and purposes, let's ignore
    that option for now.
    I have been trying to update the kernel on the imaging CD, and have had
    good luck, for the most part. I was able to update the CD to kernel
    2.6.23.9, and it boots fine, works with all our computers, and images 95%
    of them without any problems.
    However, some machines have an odd issue: The imaging process runs fine,
    with no errors, and does lay down the data to the drive. When you reboot
    the machine, you get either an "error loading operating system" error
    message, or a black screen with a blinking white cursor.
    Upon doing some further research, I've found an interesting common
    denominator. On all the machines that have this happen, the zenworks
    imaging software incorrectly reports the drive size. If I boot the CD and
    run fdisk, it correctly sees a 40Gb drive, for example. Once in the img
    program, however, it sees a 32Gb drive.
    I've tried many different kernel versions, including one compiled with the
    novell supplied 2.6.16.46-0.12, with the same result.
    I'm wondering if anyone has any ideas as to why this would happen - and if
    there is something beyond kernel updates that is required to make this
    work. Any help would be *greatly* appreciated!

    Originally Posted by Marcus Breiden
    so back to the question.. those the original cd work ;-)
    Marcus Breiden
    If you are asked to email me information please remove the - in my e-mail
    address.
    The content of this mail is my private and personal opinion.
    DIDAS AG
    So far, yes - but there are two trouble models that I have yet to test (Dell D430 / D420)
    Regardless, it'd be nice to know if the kernel replacement is technically sound anyway, if for no other reason than pure academics.

  • How do i change the file preview image for mp4 files?  I replaced the image but it doesnt show in my dock, instead it shows the first still of a movie

    http://imageshack.us/photo/my-images/21/screenshot07m.jpg/
    http://imageshack.us/photo/my-images/39/screenshot04s.jpg/
    pls help. i change the file preview of a movie file, and it shows that i have changed the preview in finder but when i open the folder on my dock, it shows the still of the movie instead.
    the image shows the film the hangover as an example. the movie poster is visible in finder, but reverts to a default movie still from the dock. this only seems to occur for mp4 files.

    its nothing to do with itunes, its movies form the internet. i got the file preview by taking an image off the internet, pressing command c and pasting it on top of the small icon in the get info section

  • Looping a short animated gif over the length of a movie ?

    Hello,
    I hope I have a good question here.
    How would you suggest looping a very simple 3 frame .gif animation over the entire length of a 3 minute video ?
    I have placed the gif animation on the timeline, and then positioned it as I want it to be, however, simply copy and pasting the video over and over again doesn't work, and adding it again from my bin, places the animation in the middle of my video, which is not where I want it.
    Thank you for any suggestions on how to go about this.
    Dave.

    You could try putting the overlay in a separate sequence with position etc as you wish, then make another sequence of several loops of the first sequence, and then use the longer version on the main timeline.

  • What best adobe programs to (design) and (create) animated gif or image ?

    Hello,
    first thank you very much for helping me,
    i am about creating an animated gif like the background you can see in war craft 3 frozen throne for a game,
    i have to design it first with high quality so i need to know best adobe programs can do that, although i need to know the easiest, so i need to know both of them the best and the easiest so if didn't made it with the best i can made it with the easiest pro, and please put in mind that i need a program to design the image from nothing so i will draw it or design it i don't know depending on the program it self but i will not use it for editing or use an image already there, i need an elite pro that allow to create the image from nothing.
    after that i need to create an animated gif for the image (gif not good for high quality images so if you know better please tell),
    for example "Her hair moves with the moving wind" so i need to move it, i don't know how so i need a program to make it move too.
    last thing at the end i need the file type be accepted in html(5) adobe games programs like flash builder or flash pro for example, i know flash pro can animate it but will not design it, thank you again.

    It may require a few different apps.  Clearly the number one app is you and your ability to conceptualize.  And, it depends on what type of animation you ultimately want produced.  Game graphics is a lot different than a web banner animated .gif.  I'm thinking Illustrator, Photoshop, Edge Animate, and After Effects.

  • Animated GIF in a Photoshop layout?

    I'm pretty new to website building stuff.
    I want to make an entire webpage layout in Photoshop CS4 and put it into Dreamweaver and turn it into a template for a website. I understand all of the slicing and importing stuff, but I want the image in the upper left corner to be an animated GIF. The image in the upper left corner would be the only animated part.
    How can I put the animated GIF into the layout? Can I put it directly in using Photoshop and have it work properly after slicing? Do I have to put it over top of the layout some how?
    Ideally, I would be able to create the layout as one thing including the Gif and slice it up from there.
    I'd like to know how this can work beforehand because I'd rather not invest a lot of time into it, just to have it fail.
    I'm sure some people would suggest Flash, but I have no idea how to use Flash, and I would prefer to use an animated GIF made in Photoshop.
    I would really, really appreciate some advice on this. Thanks in advance.
    P.S. What I'm trying to do will look a bit like this... http://www.russabbott.com/   I'm aware that this is Flash, but I'm hoping for a GIF.

    You put an animated gif into the layout the same way you put a static gif into the layout.
    As I never let Photoshop create my layouts/pages for me, I can't really advise on that, but if you send your layout to Dreamweaver with the part you want as an animated gif carefully sliced into an entity of its own with a static gif in that position, you can go back in and substitute your animated gif for it afterwards.
    And for heaven's sake, don't be afraid of "failure"...you're just testing your skills and if it doesn't work exactly as you think it will, you will have learned something.
    Beth

  • Insert animated gif or flash files (.swf) in Form?

    How can i insert animated gif or flash files (.swf) or another type of animated files in Form?

    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.

  • 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