dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Problem in load .gif file in loop

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    13

    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!

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,856

    Re: Problem in load .gif file in loop

    What class is loadImage() from?
    What code displays the image that is loaded?
    Norm

  3. #3
    Join Date
    Oct 2008
    Posts
    13

    Re: Problem in load .gif file in loop

    yes, loadImage() only load my animated image.

  4. #4
    Join Date
    Oct 2008
    Posts
    13

    Re: Problem in load .gif file in loop

    somebody helps me??

  5. #5
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  6. #6
    Join Date
    Oct 2008
    Posts
    13

    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);
    }

  7. #7
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)