JProgressBar not updating

后端 未结 3 1807
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 03:13

I have made a very simple code to show it here, i have a button that should show a JDialog to check the progress status, i am using the invoke late to go through EDT and my

3条回答
  •  日久生厌
    2020-12-02 03:34

    for (int i = 0; i < 0; i++) {
    

    You will never enter this code so will never call the updateBar(..) method

    i needs to be greater than 0 in this case. If it is 1 then updateBar will be called once, if 2 then updateBar will be called twice etc

    Also rather than doing

    Thread.sleep(25);
    

    take a look at java executors as these will help with your scheduling and remove the need for the sleep

提交回复
热议问题