Java GUI JProgressBar not painting

前端 未结 3 1850
独厮守ぢ
独厮守ぢ 2020-12-11 23:50

I have a GUI problem that I would like to get sorted out, but I am baffled as to what\'s happening and hope one of you can explain it. The code base is way too large to upl

3条回答
  •  悲哀的现实
    2020-12-11 23:59

    Are you doing whatever takes that time in the EDT? Keep in mind that AWT/Swing have a dedicated thread that does GUI work – handling event handlers, repainting the GUI, etc. If you do long-running things on that thread, Swing will not repaint.

    Try performing your task in another thread and update the progressbar from there accordingly. Use SwingUtilities.invokeLater or invokeAndWait to update the progressbar, though, to ensure that the GUI updates happen on the EDT. Otherwise things get very weird.

提交回复
热议问题