| Author |
How to get length of task for JProgressbar?
|
Bob Zoloman
Ranch Hand
Joined: Jul 02, 2006
Posts: 72
|
|
|
Hi, I am trying to figure out how to implement a JProgressbar, but I'm a little confused on the part where you get the length of the a long running task, and the currentTime() of the task. If I want to use a progressbar for a certain class do I need to have those kinds of methods inside the class that has that task? It seems like I would have to repeat a lot of code in all classes that need a progress bar. Is there a better way to do it? Thanks in advance.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24051
|
|
|
Estimating the amount of time that a task will take is, obviously, a hard (read impossible) problem. Does using a progress bar mean duplicating code? Well, yeah, kinda. If you want "X% done" kind of progress bars, then every long-running task has to periodically send an event which says "I'm X% done."
|
[Jess in Action][AskingGoodQuestions]
|
 |
Bob Zoloman
Ranch Hand
Joined: Jul 02, 2006
Posts: 72
|
|
Say for example I had 10 separate classes, and each one has a task I want to have a progress bar for, the way I understand it is that I would need a getLengthofTask(), getCurrentTime(), methods plus all the instance variables required for progress bar, etc... embedded in every single class that uses one (in this case 10). To me it seems like a really bad design... First, it reduces your classes reusablility, and you have duplicate code in every class. Is there a better design approach I could take?
|
 |
 |
|
|
subject: How to get length of task for JProgressbar?
|
|
|