繁体   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