jQuery in Action, 2nd edition*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: concerning the event-dispatching thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: concerning the event-dispatching thread" Watch "NX: concerning the event-dispatching thread" New topic
Author

NX: concerning the event-dispatching thread

Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
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 ]
Javini Javono
Ranch Hand

Joined: Dec 03, 2003
Posts: 286
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
Ulrich Heeger
Ranch Hand

Joined: Jun 06, 2003
Posts: 266
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: concerning the event-dispatching thread
 
Similar Threads
NX: concerning exception handling
NX: two questions concerning the client GUI
NX: Server GUI
NX: Unix testing or not, portability tips
NX: concerning threads & exceptions