Article View: borland.public.jbuilder.java.swing
Article #9168processing animated gifs in JLabel
From: Alan Shiers
Date: Mon, 22 May 2000 00:00
Date: Mon, 22 May 2000 00:00
28 lines
1741 bytes
1741 bytes
Hi there:
I created an animated gif file that doesn't loop continuously. It only
plays once when loaded and that's it. I designed it that way and don't
really want to change it. Now, I've also created a bean I call JGrid,
which is nothing more than a collection of JLabels. I've created a
project that makes use of the JGrid bean and during a mouseClick event
I'm loading up the animated gif file into an instance of the ImageIcon
class and passing that as an arguement to the JLabel.setIcon(Icon icon)
method for that particular JLabel. In my bean I use setIconAt(Icon icon,
int row, int col) to specify which JLabel is to receive the image. The
code in the mouseClick event goes like this:
URL url = getClass().getResource("images/explode.gif");
//'opponent' is an instance of JGrid
opponent.setIconAt(new ImageIcon(url), currentRowSelection,
currentColSelection);
This works, once! If I click on another JLabel in the JGrid I get the
gif file alright, but what I get
showing is the last frame of the animated gif. I was expecting it to
play the animated gif file from the beginning again. But it doesn't.
Does anyone know how to reset the animated gif file after it has been
run each and every time?
Regards,
Alan
Technical Details
Message-ID:
<392948DE.B461A94E@istar.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,afd1ac69cd27973e,start X-Google-Attributes: gid111d45,public From: Alan Shiers <jshiers@istar.ca> Subject: processing animated gifs in JLabel Date: 2000/05/22 Message-ID: <392948DE.B461A94E@istar.ca> X-Deja-AN: 625873003 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing