Srikanth
Srikanth

Reputation: 1930

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 using Java Swing? Please someone help me out. Thanks in advance :)

Upvotes: 1

Views: 643

Answers (2)

LoSciamano
LoSciamano

Reputation: 1119

J2SE Documentation report the same issue as example of using SwingWorker class:
SwingWorker

Upvotes: 2

user166390
user166390

Reputation:

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.

Upvotes: 6

Related Questions