• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: concerning the event-dispatching thread

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
"To do good, you actually have to do something." -- Yvon Chouinard
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic