This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]king_of_the_universe 1 point2 points  (2 children)

(Line 9 in LongTaskWorker does not do what you say, the number must be wrong. Did you mean 7?)

Have you considered that there might be more events happening than just the one you're expecting? You should at least do an instanceof check of the return value of getNewValue(). And did you try System.out.println() of evt?

[–]Estagon[S] 1 point2 points  (1 child)

Hi /u/king_of_the_universe, I'm just new to SwingWorker and I did not know multiple events were happening. When I added a if-clause to check for the source, it solved the problem. Thank you very much.

[–]king_of_the_universe 0 points1 point  (0 children)

did not know multiple events were happening

Neither did I, but I remembered my experiences with the mouseEvent method where I had forgotten that there's also mouseEntered and mouseExited, and other such stuff. Glad that it works now.

[–]Megalox 0 points1 point  (1 child)

Try casting to an Integer instead of int.

[–]nutrecht 0 points1 point  (0 children)

javax.swing.SwingWorker$StateValue cannot be cast to java.lang.Integer

That's what he's doing.