Swing and threads
843806Jul 12 2007 — edited Jul 13 2007Hi
I am unsure on the exact rules of interacting with swing objects from different threads.
My current understanding is that everything is meant to happen from EventDispatchThread ie updating resizing setting values etc.
Currently I have windows that accept user input, I capture the enter key being pressed (or okay being pressed) . I then read in all the value from the swing objects whilst in the Event Dispatch Thread and save them to intermediary variables. I then start up another thread (use thread pools) and use the intermediary variables to access the information.
I was thinking, it shouldn't be a problem to just disable the windows when I capture the event and then on the other thread read the values back in and re enable ?
Just seems like I have duplicate all my variables because I don't want to do any processing in the Event Dispatch Thread as I am accessing DB's.
For people who normally build threaded swing apps, whats the best practice on this ?
another question from this is can I set the values of these swing objects from another thread ? ie is it just the building of the swing objects that has to be done on Event Dispatch Thread ?
Thanks