This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes can you have more then one process in a swing worker Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can you have more then one process in a swing worker" Watch "can you have more then one process in a swing worker" New topic
Author

can you have more then one process in a swing worker

Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Hi all,

I have some swingWorker code working. I'm rocking the publish/process just fine to push out data to a JTextPane for logging. All works great.

Trouble is, I also want to be able to potentially update a JTableModel at the same time (as in, while the process is running, I will be removing objects from my table model). I'd like this to happen on the EDT, and not when things are done.

So can I make more then one process/publish pairing in a swingworker? I don't think i can, so then I assume I can make another SwingWorker and nest it inside the other swingWorker but that seems a bit overkill..

Is there a way to update my tableModel on the EDT from within the SwingWorker outside of publish/process?
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
I did not have success nesting a secondary swing worker inside the swing worker (i didn't think I would , but what do I know LOL).
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Jason Richard wrote:I did not have success nesting a secondary swing worker inside the swing worker (i didn't think I would , but what do I know LOL).


I so found a solution to what i was trying to do

in my process, i call fireTableDataChanged on my model. This works, but i don't like the way it works, I would hope there would be a nicer way.
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Not that anybody but myself is reading, but if somebody else stumbles across this thread.

I worked around my issue by having my using Object as my process parameter, and then checking for different objects based on what i wanted to do .

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38463
    
  23
And when somebody passes an Integer to your List?

There is something wrong with lots of instanceofs and lots of casts.
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 69
Campbell Ritchie wrote:And when somebody passes an Integer to your List?

There is something wrong with lots of instanceofs and lots of casts.


well, since it's my swingworker, I wouldn't pass anything I don't know about.

However, what would your solution be?
 
Consider Paul's rocket mass heater.
 
subject: can you have more then one process in a swing worker