Hai java devolpers,
Please give one solution for my problem.Currently i am working in Thick client(Swing) for downloading files from ftp server.Iam using JFrame with ActionListener for downloading purpose,now i want to place one progress bar to indicate the downloading process.But i cant able to place the progress bar correctly,progress bar is displayed after the completion of downloading process.
with regards,
C.Rajaguru.......
Then you're using the wrong thread(s) for processing your download; remember
that Swing is a single threaded framework, i.e. if it's doing one thing it can't do
another thing (such as drawing) at more or less the same time. I suspect you're
downloading your file in the same thread as in which the ActionListener runs.
The ActionListener runs in Swing's thread so Swing can't do anything else but
wait until your ActionListener has finished.
Instead have your ActionListener start a new Thread and let that Thread do the
file loading; it can update the ProgressBar at regular intervals. The ActionListener
itself can return almost immediately then and Swing will be free again to perform
what it does best: drawing and notifying all those listeners.
kind regards,
Jos