![](/img/trans.png)
[英]JProgressBar on button click to show the progress while sending emails
[英]Show the while remaining time with jprogressbar?
我在一個文件夾上有幾個大的DB文件,我在JAVA中處理了一段時間,如何用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;
}
非常感謝 ...
SwingWorker
。 doInBackground()
。 把循環放在里面。 偶爾調用方法publish(...)
。 process(...)
。 調用JProgressBar
的setValue(i)
。 你能舉個例子嗎?
應該使用SwingWorker
setProgress()
方法,以便“在事件派發線程上異步通知GUI”。 這里有一個例子在這里和在API 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.