0

我在一个文件夹中有几个大的 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;
    }

多谢 ...

4

2 回答 2

1
  1. 扩展SwingWorker.
  2. 覆盖doInBackground()。把环放在里面。不时调用该方法publish(...)
  3. 覆盖process(...)。打电话JProgressBarsetValue(i)
于 2011-11-08T08:16:16.827 回答
1

你能给我举个例子吗?

SwingWorker setProgress()应该使用该方法,以便 GUI“在事件调度线程上异步通知”。此处API中有一个示例。

于 2011-11-08T08:28:44.287 回答