I've been reading about progress bars, and there are some pieces of the puzzle I can't really understand. I don't understand how to set a progress bar that shows the status of a given thread or a calling to a method that calls other methods.
The code below is a quick recap of what basically I'm doing at the moment.As you can see, I'm just showing a simple and basic pop up with a trivial message "processing information" and once the called methods are done , another pop up "Operation Complete!"... I know it's a bad approach especially because it doesn't provide any feedback to the user of what is going on.
Thread t = null;
try {
if (...) {
t = new Thread(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "processing information ....", "Wait",
JOptionPane.INFORMATION_MESSAGE);
}
});
t.start();
}
if (response == null)
waitResponse();
if (...) {
//do some controls
{
if (...)
throw new AssertionError("you can't edit that field..");
}
}
//
if (type.equals("A"))
methodA(1234);
else if (type.equals("B"))
methodB(1234);
else if (type.equals("C")) {
methodC(1234);
} else if (type.equals("D")
methodD(1234);
if (...) {
t = new Thread(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Operation Complete!", "Done",
JOptionPane.INFORMATION_MESSAGE);
}
});
t.start();
}
I would to understand/learning how can I use a progress bar to show the status of the program. I've read some information about doInBackground() , publish(int i) , process(List chunks) but I don't understand how to use them.