开发者

JTable wait indicator

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 o开发者_JAVA百科ther options like ajax activity flower.


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


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()


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜