• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SwingUtilities

 
Eddie Long
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How does SwingUtilities.invokeLater and SwingUtilities.invokeLaterAndWait know which event dispatching thread to run in when you have more than one JFrame in an application?
NB: Assuming that all the JFrames have been realized but only one is displayed at a time using setVisible(true/false) where necessary

Also

Is SwingUtilities and Swingworker [not in the J2SE but supplied by Sun] any use in a distributed environment?

Thanks in advance.
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eddie Long:
Hi all,
How does SwingUtilities.invokeLater and SwingUtilities.invokeLaterAndWait know which event dispatching thread to run in when you have more than one JFrame in an application?

There's only one event dispatching thread in an application.

Originally posted by Eddie Long:

Is SwingUtilities and Swingworker [not in the J2SE but supplied by Sun] any use in a distributed environment?

SwingUtilities is used to place tasks on the event thread. Only code which interacts with the GUI need be on the event thread, so the environment (distributed or not) doesn't really figure into it. SwingWorker is used to move tasks off the event thread. It's really a utility wrapper for creating a thread. Again, useful in all environments. Check out the Java Tutorial on
Swing: How to use Threads for more info.
[ February 07, 2005: Message edited by: Joe Ess ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Watch this. I never fully understood Swing and Threading until I saw that. Now it is all crystal clear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic