Java SwingWorker - multiple SwingWorker classes in the wild

One thing I've learned as I'm getting back into Java/Swing development is that there is more than one SwingWorker in the world these days.

While I was away, Sun introduced this new SwingWorker in Java 6:

And to help Java 5 developers stay compatible with that Java 6 SwingWorker, they also released a back-port of it, which can be found here:

That back-port uses a different package name than the Java 6 SwingWorker, but the class signature is otherwise the same.

Just a few years ago I used a different SwingWorker, which is apparently now called the "Version 3 SwingWorker". To be clear, you do not want to use that SwingWorker any more, and because of that, I won't link to it here.

Java SwingWorker - summary

Again, if you're using Java 6, you can use the Java 6 SwingWorker, and if you're using Java 5, you can use the Backport of the Java 6 SwingWorker. These SwingWorker's will include method names like these:

  • doInBackground
  • done
  • get
  • cancel

The Version 3 SwingWorker uses different method names, and it is not compatible with the Java 6 SwingWorker.

I hope to have some decent SwingWorker examples out here shortly, but I thought I'd just start with this important note.