You never appear to call setProgress(...)
inside of your Task SwingWorker. If the progress property never changes, then calling getProgress()
will not show any changes.
To solve this, you must rig your doInBackGround to call setProgress(...)
as things are progressing. This will notify any PropertyChangeListeners that are listening to the worker. You would likely do this inside of the while loop where you process the file.
As an aside, you have another dangerous SwingWorker that appears to be making Swing calls, such as setText(null)
from withn the doInBackground()
method:
SwingWorker<Void, Void> workerClear = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
txt1.setText(null);
txt2.setText(null);
txt3.setText(null);
return null;
}
};
You don't want to do this, make Swing calls off of the EDT. In fact I see no reason to use a SwingWorker at this spot in your code and many reasons not to.
Also, and again as per my comment, you are posting too much code unrelated to your problem. Next time here, please post less code by whittling your code down to a manageable amount of code that compiles, runs, and shows your problem, an sscce.