I’m trying to mess around with a progressBar for the first time. I want to keep record of the thread using a progressBar — I did look at this but it didn’t help.
Does anyone know how to do this?
I tried using the bytes of the mp3 file to update the progressBar but I was unsuccessful.
I want to use the thread which I use to play the mp3 file.
This is a screenshot of the mp3 player.

The usual problem is, that you also need proper GUI refreshes when updating the progress bar’s value. I did async loading with progress bar some time ago, where I used exactly that tutorial.
Note, that with compressed audio files, the usage of byte counters might not be accurate, without doing complete decompression initially, what might not be what you want.
It is essential of course, that you set up the progressbar’s value and min & max appropriately using the constructor and/or setMaximum(), setMinimum() and setValue(), before starting to play, e.g.
but not
from your worker thread, use the
PropertyChangeListenerinterface and setProgress() ofSwingWorkerfrom within the worker instance as in following example.Just adapt the code to your needs:
http://docs.oracle.com/javase/tutorial/uiswing/examples/components/ProgressBarDemoProject/src/components/ProgressBarDemo.java