Patrick Vanhuyse
Oct 11th, 2004, 09:10 AM
I would have code like :
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
}
}
The job is scheduled using Spring Framework (org.springframework.scheduling.timer).
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 ?
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
}
}
The job is scheduled using Spring Framework (org.springframework.scheduling.timer).
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 ?