Trying to use the Netbeans ProgressBar to show long running tasks, having problems with dependancies and libraries

StackOverflow https://stackoverflow.com/questions/17548977

Question

I have an application built on top of NetBeans. We have some long running jobs that I'd like to keep running in the background, but allow the user to see progress on the bar on the lower right.

E.G:

Opening Projects Progress Bar

I can't seem to access it from my code.

Initially I didn't have this library

org.netbeans.api.progress.ProgressHandle;

org.netbeans.api.progress.ProgressHandleFactory;

I had to go out and hunt down the JAR file. That doesn't make whole lot of sense to me, I figure it should be available.

This creates an error when I try to call the ProgressHandle into effect, I get this error java.lang.ClassNotFoundException: org.openide.awt.StatusLineElementProvider …

Followed by a stack trace. Obviously I don't have all the packages necessary to operate this.

What the big question is then, what am I missing as far as accessing these NetBeans libraries correctly?

Thanks,

Here's the code when I'm trying to call the progressbar into action

`

ProgressHandle progr;
 if (thread == null) {
            thread = new Thread() {
                @Override
                public void run() {
          progr.start();
          progr.progress("Sending backup to remote server.");
… //Some code that sends a backup
 progr.finish();

`

I'll be rewriting this question a few times, until I think it's clear, I'm open to input

Was it helpful?

Solution

Add a module dependency on Progress API. Right click on your module > properties.Select Libraries from the left panel. Click Add to open up the module dependency dialog. Select Progress API and click OK. Now you have the dependency on Progress API and you can use it as

ProgressHandle ph = ProgressHandleFactory.createSystemHandle("My Task");
ph.start(100);

Edit: Also u dont have to add any jar files.. The Progress API module dependency will take care of that

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top