Manage GUI and EDT in a multi-task application

前端 未结 3 1431
终归单人心
终归单人心 2021-01-20 21:44

I developed a Java application for creating and extracting an archive - like WinRAR. You can create several archives at the same time with multithreading. And recently, I wa

3条回答
  •  伪装坚强ぢ
    2021-01-20 22:23

    1. Put and display JProgressBar in a JDialog, and don't create a new Top-Level Container. Create that once and re-use that

    2. Long timed and heavy code would be better redirected to the BackGround Task

    3. You can move with progress in JProgressBar from a background task

      • only if GUI related code is done on EDT more Concurrency in Swing

      • and there are two correct ways to do it

        • by using SwingWorker

        • from Runnable#Thread but GUI rellated code must be wrapped into invokeLater()

提交回复
热议问题