Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.8k views
in Java FTP by
Hi,

i have some problems using FTPProgressMonitor. There are 3 classes:
Main (SWING) (with a progress bar),
ftp (doDownload, doUpload),
and FtpProgressMonitor (bytesTransferred).

I try to pass a reference to progress bar, like this:
public void bytesTransferred(long count) { 
        this.count = count;
        float answer = (((int)count / (int)MyNum)+1 ); 
        System.out.println(answer + " : " + answer );
        j.progressbar.setValue((int)answer);
} 

But the progress bar do nothing. I only receive bytes transferred on console, and only 2 times then my program hangs-up.

Please, help me..

nic

5 Answers

0 votes
by (162k points)
I suspect you'll need to do a bit more to get the progress bar to actually update its display. You may also need to perform the upload in another thread.

Our edtFTPnet Express product, which provides asynch transfers, may be of use to you when it is released.

http://www.enterprisedt.com/products/edtftpnetexpress/

Hi,

i have some problems using FTPProgressMonitor. There are 3 classes:
Main (SWING) (with a progress bar),
ftp (doDownload, doUpload),
and FtpProgressMonitor (bytesTransferred).

I try to pass a reference to progress bar, like this:
public void bytesTransferred(long count) { 
        this.count = count;
        float answer = (((int)count / (int)MyNum)+1 ); 
        System.out.println(answer + " : " + answer );
        j.progressbar.setValue((int)answer);
} 

But the progress bar do nothing. I only receive bytes transferred on console, and only 2 times then my program hangs-up.

Please, help me..

nic
0 votes
by
Hi,

firstly i'll thank you for your answer.

>>You may also need to perform the upload in another thread.

I only need to perfom the download. So i think i do not need another thread.

>>I suspect you'll need to do a bit more to get the progress bar to actually update its display

What could i do displaying the bytes transferred on my progress bar. The method "void bytesTransferred(long count)" shows the bytes on console - normally i could do what i want inside it, i.e. displaying on textareas or something like that.

Perhaps you could give me a more detailed hint solving my problem.

Many thanks!

Nic
0 votes
by
Hey,

nothing to do. I solved the problem.
Thank you,

nic
0 votes
by
Hi,

I have the same problem, can you help me? :?

Many thanks
Luca
0 votes
by
Bruce was right.
Try it with threads.
AnObject.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent e) {
   if (connect("USER@REMOTEHOST.COM"   
                     "passWord"                        
                     "ipProxy")) {                           
                 Thread downloaderORuploader = new Thread() {
                     public void run() {
                         // here methods for put OR get
                         disconnect();
                     }
                 };
            downloaderORuploader.start();
            }
         // indivual code
         }
      });


In methods "get" and/or "put" invoke another method, like setProgressValue(int Value) within another thread-based runnable when bytes arriving.

nic

Categories

...