I have several big DB file on a folder that I handled them with a while in JAVA, how can I show the remaining time as percent with JProgressbar ?
public int countTrueAmr(String text, String under,String value, String search) {
int sLen = under.length();
int count = 0;
int index = text.indexOf(under + value, 0);
int nextIndex = text.indexOf(under, index + sLen);
while (index > 0 && nextIndex > 0) {
count += countString(text.substring(index, nextIndex), search);
index = text.indexOf(under + value, index + sLen);
nextIndex = text.indexOf(under, index + sLen);
if (nextIndex < 0)
nextIndex = text.length();
}
return count;
}
thanks a lot ...
SwingWorker
. doInBackground()
. Put the loop inside. Call the method publish(...)
once in a while. process(...)
. Call JProgressBar
's setValue(i)
. Could you please give me an example?
The SwingWorker
setProgress()
method should be used so that the GUI is "notified asynchronously on the event dispatch thread ." There's an example here and in the API .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.