Using JProgressBar?

I anticipated that a JProgressBar set to indeterminate would continue to scroll when placed on a form that then goes into a long process.

I hide the bar onLoad, show it when a process starts , and it then starts to scroll but almost immediately stops for the remainder of the process?

Should I be displaying this progress bar in a dialog on top of this ‘working’ form or did I miss something in order to make it work?

Using application.updateUI() in my loop massively slows the process.

I guess application.updateUI() is necessary. Without that, the GUI and your progress bar will not be updated. You could do that every x times of an iteration only to not slow down your process too much.

patrick:
I guess application.updateUI() is necessary. Without that, the GUI and your progress bar will not be updated. You could do that every x times of an iteration only to not slow down your process too much.

Thanks Patrick - yes it looks like using it on say every 5th loop might be the answer.

In the past I think I’ve used a MOD() function but I cant see anything similar in Servoy - or something that will take the loop index and divide by 5, and be true if the result is an integer and not if its a decimal.

Any pointer from your experience Patrick?

Hi Ian,

You can use the following code:

if ( i%5 == 0 ) {
    // update on every 5th item
    application.updateUI();
}

Which is the JS equivalent of your MOD() function.

ROCLASI:
Hi Ian,

You can use the following code:

if ( i%5 == 0 ) {
// update on every 5th item
application.updateUI();

}



Which is the JS equivalent of your MOD() function.

Very lovely thanks Robert! Just what I needed - and using every 5th loop extended the process time by only 10 seconds total which is acceptable - and I noticed any longer and the progress bar movement is too sluggish to be attractive - so looks like 5 is the magic number in this instance.

Thanks Robert and Patrick again.

patrick:
I guess application.updateUI() is necessary. Without that, the GUI and your progress bar will not be updated. You could do that every x times of an iteration only to not slow down your process too much.

So the progress bar only will be updated in Smart Client, isn´t?
Any trick for use it in Web Client?

Thanks

Hi Victor,

The JProgressbar bean is not web enabled so you can’t use it in Webclient. I guess you can create your own progressbar using HTML and a global field that you update every x times.

Hi Robert,

thanks for your tip. I think that I’m going to use an animated gif with a status text so I have the same code in WC and SM.