I would have code like :
The job is scheduled using Spring Framework (org.springframework.scheduling.timer).Code:interface JobListener { void begin(); void end(); void completed(int percent); } class Job extends TimerTask { JobListener listener; void run() { listener.begin(); for (...) { listener.completed(i); } listener.end(); } } class View extends AbstractView implements JobListener { void begin() { getStatusBar().setMessage("Begin"); // And/or other Swing stuff } void end() { getStatusBar().setMessage("End"); // And/or other Swing stuff } void completed(int percent) { getStatusBar().setMessage("Completed " + percent); // And/or other Swing stuff } }
Since the job doesn't run in the Swing's thread, shouldn't this cause problem with Swing ?
I think it would.
How can I do that ?


Reply With Quote