-
August 14th, 2011, 09:56 AM
#16
Re: Weird SwingWorker Bug HELP!
Whats interesting is that setProgress is supposed to throw IllegalArgumentException when it gets a value outside the 0-100 range. And adding a try, catch around your getData method does show the exception, but without that, the exception disappears into nothingness. I started tracing into the SwingWorker source, made it as far as FutureTask.Sync.innerSetException, then gave up. The disappearing exception might be a SwingWorker bug.
-
August 14th, 2011, 12:02 PM
#17
Re: Weird SwingWorker Bug HELP!
Yeah.... From what I can see.... I think setProgress(100 or 101) calls done() for some reason... I think thats at least one of my problems.... The math.min helped a little too...
Thanks for everything man
-
August 14th, 2011, 12:38 PM
#18
Re: Weird SwingWorker Bug HELP!
I should've tried this before, but after completely removing setProgress(), everything works fine.
So I then moved the setProgress out of the inner for loop so it just checks with the width to make things simpler. Then I made another check to make sure newProgress > 0 && newProgress < 100 && newProgress != getProgress() before setting the progress. This works flawlessly.
I've kinda concluded that SwingWorker is a very touchy class that needs much more documentation and transparency.
-
August 14th, 2011, 03:44 PM
#19
Re: Weird SwingWorker Bug HELP!
At least in the SSCCE you posted, the only problem was passing a value outside the 0-100 range to setProgress. Check the setProgress docs & you'll see it expects the parameter to be 0-100 & will throw an IllegalArgumentException otherwise. The problem is that SwingWorker swallows exceptions in certain cases. This seems to be a known issue:
http://www.google.com/search?q=Swing...ows+exceptions
For the SSCCE, the only change required was ensuring not to pass > 100 to setProgress. But if you want to continue to use SwingWorker, I'd suggest also explicitly adding a try,catch(Exception) clause around the entire doInBackground code to avoid any exceptions being swallowed. Either that or use one of the solutions in the google link I posted (I haven't read them though).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|