trying to use progress bar for the first time.
I'm not sure how I need to use this progress bar. I have a bunch of threads that are doing different things like extracting files. I would like a progress bar to show up. I've been working on this for days now.......... Anyway, My main class has all of my GUI and I have another class called "extractjboss" that handles all of my threads. I have a progress bar in the main GUI class called "private javax.swing.JProgressBar jProgressBar1;" It shows up on the last page where I calling "final extractjboss t = new extractjboss();" "new Thread(t).start();" to start the threads. Now here is the code that I have in extractjboss. Everything build fine but when I run the program I get this error.
"Exception in thread "Thread-2" java.lang.NullPointerException"
"at setup.extractjboss.run(extractjboss.java:41)"
"at java.lang.Thread.run(Thread.java:595)"
"Java Result: 1"
Just so you know I've only been working with java for two weeks so I'm still learning how everything works. Thanks for your help.
Code:
import javax.swing.filechooser.FileSystemView;
import java.io.*;
import Shared.*;
import java.util.zip.*;
import java.util.*; //import java.util.jar.*;
import java.lang.String.*;
import javax.swing.*;
public class extractjboss implements Runnable {
static JProgressBar jpb;
static extractjboss _this;
public extractjboss (){
_this = this;
}
private final Object threadLock = new Object();
protected final void waitForSignal() throws InterruptedException {
synchronized (threadLock) {
threadLock.wait();
}
}
SharedInstall install = new SharedInstall();
String curDir = System.getProperty("user.dir");
// worker thread
public void run(){
while(true){
for (int i = 0; i <= 100; i++){
jpb.setValue(i);
jpb.updateUI();
System.out.println("actionPerformed sets jpb value to: "+i);
try{Thread.sleep(50);} // make the process last a while
catch (InterruptedException e){}
}
try {
String prop = install.ReadProps("jboss");
File[] rootDirs = File.listRoots();
System.out.println(rootDirs.length);
File rootDir = null;
int compare = 0;
for (int i = 0; i < rootDirs.length; i++) {
compare = rootDirs[i].compareTo(FileSystemView.getFileSystemView().getHomeDirectory());
if (compare < 0) {
rootDir = rootDirs[i];
}
}
System.out.println(rootDir);
String command = curDir + "\\" + prop;
System.out.println(command);
install.runUnZip(command, rootDir);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
protected final void signalEndWait() {
synchronized (threadLock) {
threadLock.notify();
}
}
}
Thanks for all the help