Author Topic: [Java] Tasks with progress bars  (Read 3606 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
[Java] Tasks with progress bars
« on: October 31, 2007, 01:09:36 pm »
I've created a couple of classes for managing tasks. When one or more tasks are active, a window will appear with a progress bar showing the status. There are two types of tasks: determinate tasks and indeterminate tasks. The former have a set number of steps; calling advanceProgress() will advance the counter and the progress bar. This type will automatically complete() when it reaches 100%. The latter update by a call to updateProgress(String), which will change the string used in place of the progress percentage.

This is great for monitoring file downloads! Actually, that's the reason I started this. Set each step to 1kB (filesize/1024 steps), and use "kB" for the units.

Sample use:
Code: [Select]
Task ind = TaskManager.createTask("indeterminate task");
Task det = TaskManager.createTask("determinate task", 10, "steps");
for(int i = 0; i < 10; i++) {
ind.updateProgress(Integer.toString(i));
Thread.sleep(100);
det.advanceProgress();
}
ind.complete();



http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/util/task/
« Last Edit: October 31, 2007, 04:34:23 pm by Camel »

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!