i have a situation in my code
where i need to monitor a long running download of a file
i can use swing workers but the problem with them is you can use them just once not twice or more , so this is definetely not gonna work in my case
if you were in my situation what you would be doing ?
Winston Gutkowski wrote:It depends. Is the download process a Java one?
I'm not familiar with SwingWorker, so I can't comment, but I think I'd probably just make the download process a java.util.Observable, and have whatever needs to check on it implement java.util.Observer.
I suspect there are also more "GUI"-specific solutions, but Observable/Observer has always seemed very straightforward to me.
Stephan van Hulst wrote:You will definitely want to use a SwingWorker. It's perfectly tailored for this sort of thing.
What exactly is the problem you're experiencing with them?
the problem with swing worker is
we can call its execute() only once ..i know that from javadocs and also i have tried it execute 1st time but not 2nd time
means we cannot create multiple instance of swingworker i suppose ?
Stephan van Hulst
Joined: Sep 20, 2010
What makes you think you can't create multiple instances? The constructor and execute() method are two different things. Just create a new worker for each download.