The Property Change Event Of Progress Bar Not Firing

后端 未结 2 545
难免孤独
难免孤独 2021-01-24 18:15

I am using JProgressBar for Showing The Progress Of Data Loaded From from DataBase . I am using SwingWorker Class To Load The Data In BackGround Thread using Tutorial!

T

相关标签:
2条回答
  • 2021-01-24 18:55
    • You can implement Runnable; it avoids Future and generics, but it is easy to get wrong.

    • This answer compares SwingWorker and Runnable for similar action; SwingWorker has the advantage, but it requires better knowledge about Java Essential Classes.

    • SwingWorker is proper way and is designated for single long running thread; for multithreading, invoke SwingWorker from Executor.

    • Example about SwingWorker.

    • Example about get() exceptions from SwingWorker and PropertyChangeListener.

    0 讨论(0)
  • 2021-01-24 18:59

    @mKorbel has cited many instructive examples, but the key is invoking setProgress() from the worker's doInBackground(). SwingWorker handles the required synchronization. Several helpful answers expand on the topic in this related Q&A, including a reference to this example.

    0 讨论(0)
提交回复
热议问题