Display Progress by multi threading in java
I am trying to call a function initialStep() of MainApp class from ProcessStatements class. When the function initialStep() is called, i want to show progress bar to the user till the initialStep() function completes the execution.
How can i do this usi开发者_如何学Gong Java Swing? Please someone help me out. Thanks in advance :)
I recommend using a SwingWorker for the task.
The main issue is that the Swing stuff needs to be done on the EDT (Event Dispatch Thread). The SwingWorker takes care of all that. The progress bar can be a simple JProgressBar in a window or whatever is desired.
Happy coding.
J2SE Documentation report the same issue as example of using SwingWorker class:
SwingWorker
精彩评论