-
May 27th, 2010, 06:03 AM
#1
Problem in load .gif file in loop
Hii all,
to make my program more interactive, I try to load one .gif file whenever it has a loop. But the animation in loop do not operate until the loop ends. Certainly, it ruins my purpose...
my code like this:
/*
loadImage("processingImage.gif"); //embed animation image in label object.
for(int i = 0; i....; ....){
}//end loop
*/
My animated image paused during the loop. It only operates after the loop ends..
Please help me to explain this situation. And give me the solution...
Thanks all in advance!
-
May 27th, 2010, 09:10 AM
#2
Re: Problem in load .gif file in loop
What class is loadImage() from?
What code displays the image that is loaded?
Norm
-
May 27th, 2010, 09:56 PM
#3
Re: Problem in load .gif file in loop
yes, loadImage() only load my animated image.
-
May 31st, 2010, 01:23 AM
#4
Re: Problem in load .gif file in loop
-
May 31st, 2010, 05:22 AM
#5
Re: Problem in load .gif file in loop
If you answer the questions that Norm has already asked you someone may be able to help you.
-
May 31st, 2010, 09:12 PM
#6
Re: Problem in load .gif file in loop
hii keang,
This is my loadImage function:
public void loadImage(){
GIF_Label = new javax.swing.JLabel();
GIF_Label.setSize(270, 168);
GIF_Label.setLocation(20, 20);
ImageIcon ii = new ImageIcon(this.getClass().getResource("Processing2.gif"));
GIF_Label.setIcon(ii);
this.getContentPane().add(GIF_Label);
}
-
June 1st, 2010, 06:58 AM
#7
Re: Problem in load .gif file in loop
You're not giving the Swing EDT (Event Dispatcher Thread) a chance to display the image because your loop is running in the same thread. To update the Swing GUI, either put the loop code in a SwingUtilities.invokeLater call, or use a SwingWorker thread. See Concurrency In Swing.
In the development of the understanding of complex phenomena, the most powerful tool available to the human intellect is abstraction. Abstraction arises from the recognition of similarities between certain objects, situations, or processes in the real world and the decision to concentrate on these similarities and to ignore, for the time being, their differences...
C.A.R. Hoare
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|