开发者

Scheduled tasks (Timers) in Swing

A GUI using Swing, must updat开发者_开发问答e part of its UI from a every 5 seconds. (output.setPage(url))

The code is running in a timer, but on every update, the GUI hangs.

How do I avoid making the UI hang?

Here is my code:

<insert code here>


Assuming you are using a setPage() method of JEditorPane, the event dispatch thread is blocked while the page is fetched. Using SwingWorker is a reasonable alternative.

Addendum: SwingWorker is convenient for showing progress; but as an alternative, you might look into the asynchronous feature of setPage() using setAsynchronousLoadPriority().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜