• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OK to use SwingWorker?

 
Alexander Gunnerhell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone passed the exam using SwingWorker?
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alexander,
Yes, absolutely. However, it's not the easiest path through the woods.
M
 
Alexander Gunnerhell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that's good. I was thinking that only standard libs/APIs could be used.
This would mean that SwingUtilities.invokeXXX could be used but not SwingWorker, since it's not part of the standard APIs.
But if you're absolutely certain I will give SwingWorker a go.
It seems that exception handling is a bit tricky with SwingWorker. Could you elaborate about how to handle exceptions in the thread that runs SwingWorker.construct()???
 
Jack Conway
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max, are you sure? The requirements are quite clear on this:
You are permitted to use any IDE tool you choose, but you must not submit any code that is not your own work. The final program must have no dependencies on any libraries other than those of the Java 2 Platform.

Surely SwingWorker contradicts both of these requirements?
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack, I've led you astray. I was thinking of Javax.swing.Timer for some reason: I just edited out what you actually said somehow. My apologies. No, please do not use SwingWorker.
M
 
Alexander Gunnerhell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, maybe I should clarify my thoughts about this:
As Jack mentioned the assignment is quite clear about using non-standard APIs. The reason I asked anyhow is that something like SwingWorker should really have been in the standard APIs a long time ago (and I believe a more general version of SwingWorker will exist in the APIs in 1.5 in the disguise of FutureResult from util.concurrent).
Sure, I can use SwingUtilities.invokeXXX, but this will create duplicated, explicit threading code here and there in my controllers. So the question remains: Could SwingWorker be an exception to the general rule of not using non-standard APIs???
 
Jack Conway
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand your reasoning, but I really wouldn't risk it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic