Swing GUI is not updating

后端 未结 3 1054
自闭症患者
自闭症患者 2021-01-28 08:06

I have simple Java Swing application which uses zip4j to encrypt and unpack zip file. It\'s done by this part of code:

ZipFile zipFile = new ZipFile(\"dataStorag         


        
3条回答
  •  醉梦人生
    2021-01-28 08:33

    You shouldn#t do your zipping on the event dispacher thread (which is where all your event-handling takes place). Create a SwingWorker or someething like it to offload your heavy duty on a separate processing thread that can then inform the progress bar that can be updated on the EDT. With your solution all updates to the progress bar can only be processed when the EDT is free again, that is after your zip-operation is finished.

提交回复
热议问题