EDT is not working properly with recursive method while updating lable

徘徊边缘 提交于 2019-11-29 17:24:30

You're executing a task that takes a long time (iterating through every file, recursively), from the event dispatch thread. So, while this method is executing, the EDT can't do anything else. So it can't do what it's supposed to do: repaint the components and react to user events.

This task should be done in a separate thread, using for example a SwingWorker, which will notify its progress regularly in order to update the label text. The javadoc has examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!