Trying to stop swingworker

前端 未结 4 1708
面向向阳花
面向向阳花 2020-12-20 08:52

I have a custom JDialog that pops up when my SwingWorker thread fires up. The dialog just has a JProgressbar and a Button (cancel button). I am trying to figure out how to c

4条回答
  •  情话喂你
    2020-12-20 09:10

    You should call

    worker.cancel(true); //this will set the cancel flag of the worker

    Then, when you invoke isCancelled() this will return true. So, you Can check this state in your loop

提交回复
热议问题