JTable等待指示器
我有带有 JTable
的 java 小程序。由于大量数据和较差的网络带宽,执行加载表或更改表等任何操作都需要花费大量时间。
我正在考虑添加某种活动指示器,让用户知道他的请求正在处理。
在使用JProgressBar
之前,我想知道是否还有其他选项,例如ajax活动花。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的方法是设置(非动画)WAIT_CURSOR,
请参阅 http://www.catalysoft.com/ articles/busyCursor.html
对于动画光标,请参阅:
http://book.javanb.com/swing-hacks/swinghacks -chp-12-sect-2.html
The easiest way would be setting a (not animated) WAIT_CURSOR
see http://www.catalysoft.com/articles/busyCursor.html
For an animated cursor see:
http://book.javanb.com/swing-hacks/swinghacks-chp-12-sect-2.html
SwingWorker
是为此而设计的,如本示例。特别是,“请注意,从 process 方法内部更改tableModel
是安全的,因为它是在事件调度线程上调用的。”—publish()
SwingWorker
was designed for this, as suggested in this example. In particular, "Note that it safe to mutate thetableModel
from inside the process method because it is invoked on the Event Dispatch Thread."—publish()
为此,您可以使用 JBusyComponent。只需将您的表或滚动窗格包装在 JBusyComponent 中即可。但请记住在事件调度线程之外加载数据。为此,您可以按照其他答案中的建议使用 SwingWorker。 JBusyComponent 已经为此提供了一个 BusySwingWorker。
You can use JBusyComponent for this. Just wrap your Table or the Scrollpane in the JBusyComponent. But remember to load the data outside the event dispatch thread. For this you can use the SwingWorker as suggested in the other answer. JBusyComponent already provides a BusySwingWorker for this.