Results 1 to 7 of 7

Thread: Need help with ProgressMonitor class

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Talking Need help with ProgressMonitor class

    I had coded this once before not too long ago for someone in this forum and it worked great but for some reason it dosen't seem to work anymore. The only diffrence is that i am using Readers and Writers instead of Streams but i don't think that should't matter in this case. Has anyone use this class before?

    Code:
    // Created on 11/24/01
    
         import java.awt.*;    
         import javax.swing.*;
         import java.io.*;
      
      public class FileMonitor{
        
          private ProgressMonitor pm;
          private char[] buffer; 
          private int counter; 
          private int charread;
    
          public FileMonitor(Container con,String filename, Reader in,Writer out){
           try{
           buffer = new char[(char)filename.length()]; 	
           pm = new ProgressMonitor(con,"Monitoring Progress", "Initializing...", 0,100);
           pm.setMillisToPopup(0); // default value is 2000
           pm.setMillisToDecideToPopup(0);
           synchronized (in) {
            synchronized (out) {
             while(true){
                 charread = in.read(buffer); 
            if(charread == -1) break;
             counter += 1; 
              pm.setProgress(counter);
               pm.setNote(" Operation is " + counter + "% complete");          
                out.write(buffer, 0, charread);  
          }
         }
        }

  2. #2

  3. #3
    Member
    Join Date
    Nov 2001
    Location
    C2C
    Posts
    42
    what's the 'some reason'? compile error or runtime error?

  4. #4

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    The dang this just dosen't pop up. And i can't seem to figure out why. I set setMillisToDecideToPopup(0); which from what i can gather from the Java doc's is used to evlauate when to start evaluating how long the process will actually take. I set it to 0 so it should start as soon as the method is called. If setMillisToDecideToPopup(); decides that the process will take longer than setMillisToPopup(); then the progress monitor will pop-up. The default value of setMillisToPopup(); is 2000ms which is two seconds so i had to find a file that would take longer than 2 seconds to read. But then i just decided to set setMillisToPopup(0); to zero. Which then should mean that the progress monitor will pop-up all of the time.

  5. #5

  6. #6
    Member
    Join Date
    Nov 2001
    Location
    C2C
    Posts
    42

    sorry

    been busy, so didn't try your code.

    I think it has sth to do with multithreading. Did you check this forum ? perhaps it would gieve u some ideas.

    Regards,
    Mulan

  7. #7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width