JTable等待指示器

发布于 2024-11-30 08:43:47 字数 168 浏览 0 评论 0 原文

我有带有 JTable 的 java 小程序。由于大量数据和较差的网络带宽,执行加载表或更改表等任何操作都需要花费大量时间。 我正在考虑添加某种活动指示器,让用户知道他的请求正在处理。 在使用JProgressBar之前,我想知道是否还有其他选项,例如ajax活动花。

I have java applet with JTable. Due to lots of data and poor network bandwidth it takes lots of time to perform any operation like load the table or change it.
I'm thinking about adding sort of activity indicator to let user know that his request is processing.
Before i use JProgressBar, I'd like to know whether there are other options like ajax activity flower.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

嘿哥们儿 2024-12-07 08:43:47

最简单的方法是设置(非动画)WAIT_CURSOR,

// Setting cursor for any Component:
  component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  doProcessing();
  component.setCursor(Cursor.getDefaultCursor());

请参阅 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

// Setting cursor for any Component:
  component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  doProcessing();
  component.setCursor(Cursor.getDefaultCursor());

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

沙沙粒小 2024-12-07 08:43:47

SwingWorker是为此而设计的,如本示例。特别是,“请注意,从 process 方法内部更改 tableModel 是安全的,因为它是在事件调度线程上调用的。”—publish()

SwingWorker was designed for this, as suggested in this example. In particular, "Note that it safe to mutate the tableModel from inside the process method because it is invoked on the Event Dispatch Thread."—publish()

归途 2024-12-07 08:43:47

为此,您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文