Search code examples
javaswingworker

Strange results with execute() on SwingWorker task


Java newbie here...caution!

I've set this practice app up using this example as a base. Unfortunately I'm having a problem. If I just run the program, the SwingWorker task works for very small datasets but will just stall part way through larger ones. I know this app isn't the most efficient, but I can't work out why it just stalls (or even where).

I've put the code up here.

Thanks in advance.


Solution

  • Create a stack trace or use a debugger if you believe the thread has stalled. Should give you an idea. Looking at your code: Make sure you change swing components only in the swing event thread, i.e. your done code should set the text field to the result of your computation.