我需要一个非常简单的(骨架式)Java GUI进度条教程。进度条可以是“不确定性”的,并且最好有一个可更新的文本标签。
以下是一些骨架代码,希望有人能够扩展它,使其能够工作。
以下是一些骨架代码,希望有人能够扩展它,使其能够工作。
class MyFunView extends FrameView {
// class vars and other stuff...
@Action
public void excitingButtonPressed() {
/* I have n files to download */
// Download file 1, set progress bar status to "downloading file 1"
// ...
// Download file n, set progress bar status to "downloading file 2"
}
}
基本上,我该如何包装我的下载代码?(我了解需要某种Task的子类?)
非常感谢。
编辑:
我们每个人的宝贵时间都很有限,没有任何方法可以在像我希望的那样少的代码或时间内完成,因此我将不使用进度条。
downloading file..
为此,请查看ProgressMonitorInputStream
。它是专门为此而设计的,应该能够给出实际进度的指示。 - Andrew Thompson