• 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

SwingUtilities.invokeLater()

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read some docs on this method and running Threads in Swing. But could someone explain to me in laymens terms what this does? The method name and function don't seem to mean the same thing to me.
Thanks.
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I understand it (maybe wrong), all graphics painting of Swing is done in the main Swing thread, while there is another thread, called the event dispatching thread, where methods are executed that are called for example inside of listeners.
The main point is, I think, that Swing is multithreaded as is, but painting isn't as it seems to be difficult to do multithreaded painting. SwingUtilities.invokeLater ensures that the actions done inside it are executed inside the graphics painting thread. This means all methods concerning directly painting such as changing the appearance of components, populating text components with text etc. should be done in this thread - while all time consuming stuff should be done outside of it, database queries e.g.
One good _short_ article on this is:
http://www.smotricz.com/kabutz/Issue001.html
Chantal
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chantal, that clears it up perfectly. Thank you so much.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic