Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3k views
in Java FTP by
Hi,
I have downloaded and started to try the edtFTPj pacjage.

I have a GUI application and I have implemented a little class to manage file upload using ftp.

according to demo code I have implemented this in my ftp class
(inst is the instance of the GUI class)
ftp = new FTPClient();

FTPProgressMonitor monitor = new TestProgressMonitor();
         ftp.setProgressMonitor(monitor, PROGRESS_INTERVAL);
         
pm = new ProgressMonitor(inst, "file transfer", "", 0, 100);
pm.setMillisToDecideToPopup(200);
pm.setMillisToPopup(0);
         
........................



this is the TestProgressMonitor .... fsize is a public var representing the size of the file being transfered, and a percentage 0-100 is calculated and use to print on stdout and to update ProgressMonitor...

public class TestProgressMonitor implements FTPProgressMonitor {
         private long maxbytes = fsize;
         
         public void bytesTransferred(long bytes) {
                          
             float p1 = bytes / 1024;
             float p2 = maxbytes / 1024;
             Integer perc = new Integer((int)((p1 * 100) / p2));
              System.out.println(p1 + "/" + p2 + " ("+ perc+"%)");
          
              pm.setProgress(perc);
          }
} 


the problem is that it seems fine (I see the numbers in the console output ), but even if the ProgressBar dialog is displayed during transfer, it is not updated at all.
I only see an empty dialog......no progressbar, no labels, no cancel button.

do I have to run my ftp class in a separate thread to get this updated ? or am I missing something else ?

2 Answers

0 votes
by
forgot to correct, in previous post, this
pm.setProgress(perc);
should be
pm.setProgress(perc.intValue());
0 votes
by (162k points)
Yes, another thread is required if a GUI element is to be updated.

do I have to run my ftp class in a separate thread to get this updated ? or am I missing something else ?

Categories

...