matcauthon
matcauthon

Reputation: 2261

Long running process, show progress in UI

I want to trigger a long running background process (coded as a service) from the ui. But I also want to show some progress of that task to the user.

How can I achieve this? (I want to not infringe on decoupling). Is there a best practice to solve it (combining design-patterns, eg. observer and command)?

Upvotes: 0

Views: 1425

Answers (3)

Robin
Robin

Reputation: 36621

Here is another example of a SwingWorker to do the heavy work, and to update a JProgressBar which is contained in the UI to show the progress to the user

Upvotes: 3

Mare Infinitus
Mare Infinitus

Reputation: 8192

Here is an example on how to use just the observer pattern to show progress in the UI. With JAVA sample code provided:

Using Observer Pattern to track progress while loading a page

Upvotes: 1

mKorbel
mKorbel

Reputation: 109823

Have look a JProgressBar and changes for progress could be invoked from Runnable#Thread or SwingWorker

Upvotes: 3

Related Questions