here is an example, for a folder copy: (files is the File array resulting from listFiles() method, for example)
boolean folderCopying = true;
int indexOfFileBeingCopied = 0;
int filesArrayLength = files.length;
Thread t = new Thread(){
public void run() {
try { Thread.sleep(1000); } catch (InterruptedException e) {}
while (folderCopying)
bar.setValue( (indexOfFileBeingCopied / filesArrayLength) * 100);
}
};
foreach (File f in files) {
indexOfFileBeingCopied++;
// do the file copy
}
folderCopying = false;
edit: notice that you will prolly have to sleep() after a setValue, to prevent the while loop from taking all ressources