Hi everyone, I have posted this question at another thread but now I have my question a little bit more elaborated and you have to excuse the possible redundancy I have a question concerning the event-dispatching thread: In my Client's GUI the eventlisteners are getting the values not from the table itself but from the tablemodel. (one reason for this decision consists in: In my tablemodel I can get the RecNo of the row which isn't displayed in my table.) But for that way I have to ensure that the user might only be able to fire another event after the previous has completely been processed. If the events are executed within the event dispatching thread, then I'm fine. Now my question: In my ClientStarter class I have a simple instantiation with
I�m asking myself if I should replace it with:
to guarantee that the events fired by components of MyWindow may be executed within the event-dispatching thread. Do I complicate something? Comments? Regards Ulrich [ January 06, 2004: Message edited by: Ulrich Heeger ] [ January 06, 2004: Message edited by: Ulrich Heeger ]
Hi, I'm not sure I follow exactly what you are trying to do and why. But, this is probably because I am a greenhorn (ignore the "ranch hand" lable that somehow became associated with my name). In general, you are only concerned about the dispatching with respect to updating unsynchronized Swing components (if I understand what your question, which I doubt I do). May I recommend Sun's Java tutorial: there is a free Swing book at Sun's web site, and it discusses threading issues as they relate to Swing. Perhaps this will answer your question. I apologize if my response is weak and rather uninformative . But, one thing I've learned about this project, is that it forces me to go back to Sun's web site and read their tutorials: for instance, I've recently been reading up on exceptions. Thanks, Javini Javono
Joined: Jun 06, 2003
Hi Javini, you don't have to apologize I'm really happy about your help, thank you.
May I recommend Sun's Java tutorial: there is a free Swing book at Sun's web site, and it discusses threading issues as they relate to Swing. Perhaps this will answer your question.
Good advice, there now I have found some usefull informations:
Swing event-handling and painting code executes in a single thread, called the event-dispatching thread. This ensures that each event handler finishes executing before the next one executes and that painting isn't interrupted by events. To avoid the possibility of deadlock, you must take extreme care that Swing components and models are created, modified, and queried only from the event-dispatching thread. ... To avoid the possibility of thread problems, we recommend that you use invokeLater to create the GUI on the event-dispatching thread for all new applications.
So to be sure, I will use the invokeLater-method. Thanks Ulrich
subject: NX: concerning the event-dispatching thread