Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can you have more then one process in a swing worker

 
Jason Richard
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49451
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic