簡體   English   中英

用jprogressbar顯示剩余時間嗎?

[英]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;
    }

非常感謝 ...

  1. 擴展SwingWorker
  2. 覆蓋doInBackground() 把循環放在里面。 偶爾調用方法publish(...)
  3. 覆蓋process(...) 調用JProgressBarsetValue(i)

你能舉個例子嗎?

應該使用SwingWorker setProgress()方法,以便“在事件派發線程上異步通知GUI”。 這里有一個例子在這里和在API

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM