事件调度线程 - 报告
我想知道,我想将我的摇摆工作人员的某种形式的进度报告回主线程,以便我的界面可以使用随着进度增加而变化的标签进行更新,例如
正在检查 1/6...
正在检查 2/6...
..
..
我在 C# 中做了一些类似的事情,但不记得如何现在无法将逻辑传输到这个 java 应用程序。我在这里使用的是摇摆工人,而不是后台工人,
请有人启发我我需要研究什么
谢谢
I was wondering, I want to report some form of progress from my swing worker back to the main thread so my interface can be updated with a label that changes as the progress increases, for example
checking 1/6...
checking 2/6...
..
..
I did something similar in c# a while a go but cant remember how so now cant transfer the logic to this java application. Instead of a background worker i am using a swing worker here
Please could someone enlighten me on what i need to research
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于“监视”SwingWorker,有
添加PropertyChangeListener< /a>
从方法 process()
For "Monitoring" SwingWorker there are
add PropertyChangeListener
update
JLabel
from method process()你已经有了答案,甚至可能解决了你的问题。但是,仍然值得一看我对另一个问题的回答包含一个几乎完全符合您正在寻找的内容的片段
You already have an answer, and probably even solved your problem. But still, it might be worth looking at my answer on another SO question which contains a snippet which does almost exactly what you are looking for