如何使用JProgressBar显示文件复制进度?
我正在开发一个通过网络传输文件的项目,我想合并一个 JProgressBar 来显示文件传输过程中的进度,但我需要这方面的帮助。
I am working on a project that transfers files over a network and I want to incorporate a JProgressBar
to show the progress during file transfer but I need help on that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能会发现 ProgressMonitorInputStream 最简单,但如果这对您来说还不够,请查看其源代码以准确获取您想要的内容。
要使用不同的传输方法,请用适当的流替换 FileInputStream。
You probably would find a ProgressMonitorInputStream easiest, but if that doesn't do enough for you, look at its source code to get exactly what you want.
To use a different transfer method then substitute an appropriate stream for FileInputStream.
我很确定这会起作用。
I'm pretty sure this will work.
听起来您应该使用
SwingWorker
,如此核心 Java 技术提示中所述。 另请参见使用 Swing 工作线程。It sounds like you should be using a
SwingWorker
, as described in this Core Java Tech Tip. See also Using a Swing Worker Thread.好吧这里是JProgressBar的教程,也许是会有帮助的。
Well here is a tutorial for JProgressBar, maybe that will help.