Hi,
I got the progress indicator to perform as needed on the commandline.
Now my question is how to I take the data and update a swing progress bar / monitor?
I have the progressmonitor class as follows:
import com.enterprisedt.net.ftp.*;
public class ProgressMonitor implements FTPProgressMonitor {
public static long MyNum = 0;
public void bytesTransferred(long count) {
float answer = ( ( (int)count / (int)MyNum )+1 );
System.out.println(count + " : " + answer );
}
}
-----
In the main program, the gui is drawn, and the ftp portion is executed when a button is clicked. The progress bar is already drawn and awaiting use. The progress bar is a publically accessible JProgressbar, called progressBar.
// MySize was defined earlier as a long int.
MySize = ftp.size(targetFile);
//here a new ftpprogressmonitor is created from the classfile
// ProgressMonitor.class (which appears below...)
FTPProgressMonitor monitor = new ProgressMonitor();
// In the Progress Monitor class is the MyNum variable. we set it here.
ProgressMonitor.MyNum = MySize;
//Monitor is setup.
ftp.setProgressMonitor(monitor, 1024);
// Transfer type is set.
ftp.setType(FTPTransferType.BINARY);
// Download the file
ftp.get(tmpOutput, targetFile);
So, How would I get the variable 'answer' from the progressmonitor class back into the main program in order to update the progess bar?