B4J Question Progress Bar Usage

I am working on a application that list all table names in an SQLite DB the user select the tables he want to export. Then an EXCEL workbook is created and each selected table is exported into a separate worksheet. The application is working in general. I want to add a progress bar to the application to show the progress of the tables and for each table the records written.

I have the same application in VB6 and want to transform it to B4J. I try to look for an example of using the progress bar but can't find one.
 

Daestrum

Expert
Licensed User
Longtime User
Not sure if it's possible to do in pure B4J code but the way you update a progressbar from a task is

The progressBar has a property 'progressProperty', you bind this to the Tasks property 'progressProperty'.

in java its
B4X:
pb.progressProperty().bind(task.progressProperty());

This forces the progressbar 'progressProperty' to update when the tasks 'progressProperty' is updated within the tasks overridden 'call' method.
in java its (extract from my file downloader custom control, it also updates a label in real time)
B4X:
  @Override
  public Void call()throws InterruptedException,IOException {
long start = System.currentTimeMillis();
long bytesTransferred = 0L;
int n = - 1;
byte[] buffer = new byte[4096];
while ( (n = input.read(buffer)) != -1)
{
  output.write(buffer, 0, n);
bytesTransferred += n;
    updateProgress( bytesTransferred , filesize);
updateMessage(progressString(bytesTransferred)+suffix1+"("+remainingTime(start,System.currentTimeMillis(),filesize,bytesTransferred)+")");
}
output.close();
  return null;
  }

The beauty of this is, the control is updated in real time, reflecting the actual value as it changes, without the need for a timer to update the value.
 
Upvote 0
Top