Problems with animaged gif's

Hi, I'm trying to draw a ComboBox with animated gifs in the selection list.
And the problem is that the gifs are painted but always with the same image. Here it is part of the source code of the ListCellRenderer class.
In the paint(Graphics g) function I have:
"g.drawImage(((ImageIcon)icon).getImage(),rect.x,rect.y,this);"
and if I use the following we've the same result
"icon.paintIcon(this,g,rect.x,rect.y);"
It is also rewritten the function: "imageUpdate" and it makes the gif to be repainted every 100 ms (that's ok) but always paints the same image so it doesn't animate.
Any ideas?

The solution:
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
    JLabel tmpLabel = new JLabel();
    if (value instanceof ImageIcon) {
      ImageIcon tmpIcon = (ImageIcon)value;
      tmpIcon.setImageObserver(list);
      tmpLabel.setPreferredSize(new Dimension(tmpIcon.getIconWidth(),tmpIcon.getIconHeight()));
      tmpLabel.setIcon(tmpIcon);
    else
      tmpLabel.setText(value.toString());
    return tmpLabel;
}The problem was to set "list" as the ImageObserver of the icon
Bye...
Olaso

Similar Messages

  • Problem with animated .gif

    I have a problem with animated gifs. So if I set a animated gif as background and a button is over it as in the example below, then everytime the animation goes on the button disappears until I go over it with the mouse. So what can I do to solve this?
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class FrameBackImage {
              public static void main(String args []){
                   final JFrame frame = new JFrame("Frame");
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setSize(400, 400);
                   frame.setResizable(false);
                   frame.setLayout(null);
                   java.net.URL imageURL = ImageApp.class.getResource("animatedw.gif");
                   ImageIcon imageIcon = new ImageIcon(imageURL);
                 final JLabel label = new JLabel(imageIcon);
                 label.setBounds(0,0 , 400, 400);
                 frame.getLayeredPane().add(label);
                 JButton button = new JButton ("Exit");
                 button.setBounds(200, 129, 60, 60);
                 button.setBackground(Color.black);
                 button.setForeground(Color.white);
                 frame.add(button);
                 button.addActionListener(
                 new ActionListener(){
                        public void actionPerformed(ActionEvent arg0) {
                             System.exit(0);
                 frame.validate();
                  frame.setVisible(true);
    }

    In the future, Swing related questions should be posted in the Swing forum.
    Your usage of the getLayeredPane() method is something I've never seen before, so I don't know if thats the problem or not.
    How to display a "background image" is asked all the time in the Swing forum. So to familiarize yourself with the forum you can try searching the Swing forum. Using the keywords I highlighted would be a good place to start.

  • Quality problem with animated gif through flash

    i got a problem with making animated gif through flash.
    on html/swf publication it looks clear.
    but the weird thing is through gif publication, it wouldn't show. and exporting it as a movie as gif cause visual defect when put up on web.
    it looks better when you open it in a browser.
    this is how it looks for a profile gif in thumbnail mode. blocky and unclear.
    how do you get it to look good both in thumbnail mode and in browser mode. i seen other that have a clear gif in thumbnail mode.  are my setting wrong for flash? or should i just do gif in photshop instead. i heard rumors flash don't do gif very well.

    Change your gif export setting under publish...
              Dimensions         : Match movie
              Playback             : Animated
                                        : Loop continuously
              Options               : Optimize colors
                                        : Smooth
              Transparent         : Opaque
              Dither                 : None
              Palette Type       : Adaptive
              Max colors         : 99999

  • Safari 4: Problems with animated GIF

    Hi,
    since I've updated to Mac OS X 10.6 my Safari 4.0.3 has Problems with some animated GIF.
    Some of these smileys look strange.
    OS: Mac OS X 10.6.1
    Mac: iMac (24-inch Early 2008)

    HI,
    Apparently you aren't alone.
    http://discussions.apple.com/thread.jspa?messageID=10059219&#10059219
    Carolyn

  • Problem with making gifs

    I'm using the photoshop portable cs5 and I'm having a problem with this bar i have detach in red, just doesn't appear. I have installed others photoshop, but I keep with the same problem. Someone can help me? Thanks, anyway. Sorry for the bad english hehe

    Don't worry about your English.  You have a bigger, ethical problem.
    You have an illegal version of Photoshop that must be wiped off your hard disk immediately.
    Message was edited by: station_two

  • Problem with animated gif image getting displayed

    My problem is that my animated image does not get displayed properly. I am extending JButton and the button already contains a static image. I want to display the animated image over the static one for some reason. If I replace the animated image with a static gif, then there is no problem.
    Here is the code that I am using
    Icon anim = new ImageIcon((new ImageLoader()).getImage("/graphics/busy.gif"));
    // thread to call displayAnim method
    class ColorThread extends Thread {
    ColorThread() {
    public void run() {
    while (AnimFlag) {
    try {
    displayAnim();
    Thread.sleep(400);
    } catch (InterruptedException e) {
    public void displayAnim()
    repaint();
    public void paint(Graphics g)
    super.paint(g);
    int x=5;
    int y=0;
    if ( AnimFlag) {
    anim.paintIcon(this,g,x,y);

    This code is working fine for JRE 1.2 and the animation is displayed. The problem is with JRE 1.3. when there is no animation, neither is there any image getting displayed.

  • 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"

  • Duration problem with animated gif

    Hi!
    I love the animated gif feature and have used it several times successfully.
    This time, it seems to ignoring my settings for duration. I've set the number as high as 1500/100, but when I preview in browser (Mac Safari or Firefox), the images just whip by. I did slice the animated area and optimize it as an animated gif and export it. When I worked with it again this morning, the first image reflected the 1500/100, but the rest are still racing. I've tried to attach file here.
    Also, I'm wondering if this really should be done in Flash rather than FW. The client wants maybe 5 or 6 images and with the 7 test I have now, I see we're at 216K file size. I don't know flash but if the blog theme we use doesn't have something set up, I assume I'll just outsource the Flash development.
    Thanks,
    Caryn

    Okay...it works for me, but....
    One thing to be careful of is saving vs. exporting. When you create your file, you should save it as a Fireworks .png document. Then, to produce your animated .gif, you should export it. I like using the Image Preview (under the File menu), as I can tweak any of the settings I want. Other people prefer the Export item and optimize their output.
    There are two kinds of .png files. A Fireworks .png has all the layers, vector shapes, Web layer, active filters, and special proprietary information that Fireworks uses. A flattened .png is just a bitmap, whether it has 32, 24, or 8 bits. There's no distinction between these files based on the extension. Another user once suggested using .fw.png for Fireworks documents and .png for exported .pngs and I found that a good suggestion.
    In any case, a good rule to follow is to use save when you want a Fireworks .png and export when you want a Web-ready bitmap of any format.
    So, this is my "but." I took your file and changed the durations of the other frames. I saved it as a Fireworks .png. I then went to File > Image Preview and selected Animated GIF as the format. From the Animation tab, I set the number of loops to 3 and exported. I then saved the .png again to store the loop information.
    Here's the .png (474k):
    Here's the animation (303k):
    Given that the .gif format does't have the colors to reproduce photographs well, I still recommend you look into image rotators. These are scripts that can cycle through a set of images. See this thread:
    http://forums.adobe.com/thread/518231?tstart=1

  • Transparency problem with animated gif within AJAX overlay

    Hello all,
    I have designed and animated a loading spinner in Photoshop CS3, which needs to sit within an Ajax overlay, with transparency set to 75.
    I tried exporting the spinner as an animated gif with a transparent background (using Save for Web), but it gave the animation a pixelated outside edge. Does anybody know how to remedy this?
    As the Ajax overlay is semi-transparent, I tried exporting the animated gif with a black background and transparency set to 75%. I ticked the transparency box in the export window, but once it is loading in the Ajax it doesn't seem to be transparent (see here: http://www.chrisgartside.co.uk/flash/Screenshot.jpg)
    Any help is very much appreciated.
    Best wishes,
    ruth.

    I forgot to mention that the Ajax pop-up is fired up from a Flash gaming applet.
    Thanks very much in advance.
    ruth.

  • Problem with BlueSquare57.gif

    The GIF example file seems to have a couple of problems.<br /><br />1. The spec states that the GIF Application Identifier is 'XMP Data'. The string in the file is 'XMP data' - note lower case d.  So which is it?<br /><br />2. My DOM parser doesn't like the XML that is the <rdf:RDF> node.<br /><br />specifically it complains:<br /><br />....XMLParseException: Namespace prefix 'xapBJ' used but not declared.<br /><br />I think the problem is  the <xapBJ:JobRef/> node which appears all by itself, not in and RDF Description node. There is no xapBJ namespace declaration in scope for this node.  <br /><br />Comments?<br /><br /><rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'><br /><rdf:Description about='' xmlns:pdf='http://ns.adobe.com/pdf/1.3/'></rdf:Description><br /><rdf:Description about='' xmlns:xap='http://ns.adobe.com/xap/1.0/'></rdf:Description><br /><rdf:Description about='' xmlns:xapBJ='http://ns.adobe.com/xap/1.0/bj/' xapBJ:JobRef=''/><br /><xapBJ:JobRef/><rdf:Description about='' xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/' xapRights:Marked='True' xapRights:WebStatement='www.adobe.com'></rdf:Description><br /><rdf:Description about='' xmlns:dc='http://purl.org/dc/elements/1.1/'><dc:title><rdf:Alt><rdf:li xml:lang='x-default'>BlueSquare57.gif</rdf:li></rdf:Alt></dc:title><dc:description><rdf:A lt><rdf:li xml:lang='x-default'>Blue Square 57 example of .gif file.</rdf:li></rdf:Alt></dc:description><dc:rights><rdf:Alt><rdf:li xml:lang='x-default'>This file is public domain</rdf:li></rdf:Alt></dc:rights></rdf:Description><br /></rdf:RDF>

    You where given the answer in your other posting.
    The answer was "search the Swing forum", not "repost the same question in the Swing forum".

  • Problems with animated gifs in Premiere Pro

    Hi everyone,
    I need some help with my video project - I made some animated gifs that I want to add to the end credits. Importing them etc. works just fine, but in the video, the images always show up with a white background (white "box" around the animted figure), although the gifs definitely have a transparent background to start with. If I import them e.g. as png stills, they are transparent.
    Am I doing something wrong? Or is that a Premiere thing&do I have to re-create the animations inside Premiere?
    I couldn't find anything on this in the forum and I am grateful for any help/suggestions!
    Thanks&have a great weekend!
    Patrick
    I am using Premiere Pro CS 5 on a Mac. The gifs were created in Photoshop.

    Welcome to the forum.
    When Still Images show as black, the first things that I investigate is the pixel x pixel dimensions of the images. With many Stills, even if they are within the allowed pixel x pixel range, one's computer's resources can be used up, and an alternate workflow might be useful - Scale the Images to match the Frame Size of the Sequence, prior to Import, in a program, like Photoshop. This ARTICLE might be helpful.
    The second thought is that the video driver is no longer performing properly, and needs to be updated. What is make/model of your graphics card, and what is the current number/date of your installed video driver?
    Good luck,
    Hunt

  • Problems with animated gif with ftp publishing

    Hi
    I have successfully tested a site using mobile me. Ready to go online I uploaded it to an ftp host and the animated gifs are not animating, they appear static. Works fine on mobile me so the data is obviously correct. Anyone know why Im having this problem?

    think ive solved it

  • Has Safari 2.0.3 problems with animated Gifs?

    http://www.webgraphics.at/macnews/photo.gif
    This animation runs under Firefox liquid and under Safari badly.
    Newton 120, iMac Blueberry, MDD, 12 PB G4, 15 PB G4, iMac G5, iPod 15, iPod Shuffle, iPod Nano   Mac OS X (10.4)  

    Same problem.
    Gif isn't shown propper anymore. ( www.iguanaloco.ch for example)
    In earlier Safari version it was no problem.
    But I can not tell when the problem started, nor after wich update.
    At my friends iMac G3 OSX 10.3, everything is OK.
    My computer's are up to date.
    PowerBook G4 667, and the PowerMac G5 dual 1.8, both the same situation to the Gif's.
    Sorry if my language is not so nice :
    Apple, you made ****, please correct it asap. and don't becom windows.
    Thanks.

  • Problem with ImageIO.read and ImageReader GIF becomes dark

    I am having problems with certain GIF images loading completely dark. I previously had problems with certain JPGs colors being distorted http://forum.java.sun.com/thread.jspa?threadID=713164&tstart=0. This was a problem in an old JDK.
    Here is the code:
                java.awt.image.BufferedImage bufferedImage = javax.imageio.ImageIO.read( new java.io.File("javabug.gif") );
                System.out.println( bufferedImage );
                javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("badcolors.jpg") );
                javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("badcolors.png") );BufferedImage Read is:
    BufferedImage@337838: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@119cca4 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1536 height = 1152 #numDataElements 3 dataOff[0] = 2
    Here is the GIF
    http://www.alwaysvip.com/javabug.gif
    I am using jdk1.5.0_06
    If I use java.awt.Toolkit.getDefaultToolkit().getImage instead of ImageIO.read, the problem no longer exists.
            java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().getImage( file.toURL() );
            java.awt.MediaTracker mediaTracker = new java.awt.MediaTracker( new java.awt.Container() );
            mediaTracker.addImage( image, 0 );
            mediaTracker.waitForID( 0 );
            java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( image.getWidth( null ), image.getHeight( null ), java.awt.image.BufferedImage.TYPE_INT_RGB );
            java.awt.Graphics g = bufferedImage.createGraphics();
            g.setColor( java.awt.Color.white );
            g.fillRect( 0, 0, image.getWidth( null ), image.getHeight( null ) );
            g.drawImage( image, 0, 0, null );
            g.dispose();
            javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("goodcolors.jpg") );
            javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("goodcolors.png") );BufferedImage Read is:
    BufferedImage@1bf216a: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 1536 height = 1152 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    Is this another bug in the JDK? Is there a possible workaround where I can still use ImageIO.read?

    I figured out the problem. It was an actual BUG in the JDK!
    The code failed with the following JDKs:
    java version "1.5.0_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
    Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
    java version "1.5.0_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
    Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
    The code ran sucessful with this JDK:
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
    If you are using the ImageIO classes, I highly suggest you upgrade to the latest JDK.
    Best,
    Scott

  • Help with animated gif background once opened in Photoshop c33 extended

    I often work with animated Gif's and a
    adding doggies etc to the top layer.
    I am having a problem with animated Gif with (existing transparent) background when saving from the web and opening in Photoshop cs3 extended it is changing the background to White automatically ?  ( which is not what I want)  I would like to know how to keep in the same format with the tranparent or even change to black as that is the background on my website.....do not know why it is converting it to white in photoshop or how to change....Thank you advance!

    Thank you so much....after many hours playing with ....went right too and worked perfect!!  Thank  you !!

Maybe you are looking for

  • Getting the length of a field in a database.

    I have a field in a database that has a char length of 20, is there anyway to get that length from the database.

  • Queries regarding creating Web Services in Oracle EBS 11i[Workaround found]

    Hi, We have an E-Business Suite 11i installation(11.5.10.2). In our implementation we are using some of the public APIs to insert & update data in EBS tables. Earlier this was done by calling the required PL/SQL procedures through dblinks. Now, we ne

  • Being billed for free workspace?

    Hi, I think I am being billed for using the free ML workspace, or at least misunderstand why I am being billed a monthly charge for ML.  I see a monthly charge for one ML seat, and have one workspace which was migrate from the preview. The workspace

  • Backup workflow fails - Find Finder Items

    I have tried to put together a simple Automator workflow to backup recently changed files to a CD as follows: [Find Finder Items]: Where:[Top level folder] Whose:[Date Modified]:[Within the last 2 weeks] [Create Archive]: Save As:[Archive File Name]

  • How to implement the Oracle Group by function in Crystal reports?

    Hi all, In SQL, for example we have a group function like: select  district,state, country, continent, sum(no.of people) from world. Now, How to implement this group function in crystal reports? Please advise. Thanks in advance.. Regards, sriram