开发者

Update JProgressBar Without Knowing Progress

I want to use a JProgressBar but I don't have any measurement of progress for how long the task will take to complete. The idea is to have a progress bar displaying the status of a shutdown process but I don't know how long it ta开发者_运维问答kes, and I have no way of editing the class that does the shutdown process.

Is there a way to use a JProgressBar without having any indication of the progress?


Call setIndeterminate(true).

From the javadocs:

To indicate that a task of unknown length is executing, you can put a progress bar into indeterminate mode. While the bar is in indeterminate mode, it animates constantly to show that work is occurring. As soon as you can determine the task's length and amount of progress, you should update the progress bar's value and switch it back to determinate mode.


You can have a JProgressBar which displays in indeterminate mode, as described here. The default animation is a 'bouncer,' that is, the progress indicator will go back and forth between the two ends of the bar until you stop it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜