News:

Holy shit, it's 2018 2019 2020 2021 2022 2023 2024, and the US isn't a fascist country! What a time to be alive. Well, shit.

Main Menu

[Java] Tasks with progress bars

Started by Camel, October 31, 2007, 01:09:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Camel

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:
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/

<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!