Results 1 to 5 of 5
Thread: SwingUtilities.invokeLater();
- 02-08-2010, 03:08 AM #1
SwingUtilities.invokeLater();
andJava Code:public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }
What's the difference? Why invoke the method in a different thread? It showed no difference. :( Any help is appreciated. Thanks in advance.Java Code:public static void main(String[] args) { createAndShowGUI(); }
Source: http://java.sun.com/docs/books/tutor...LevelDemo.java"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 02-08-2010, 05:42 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
All Swing components should be created on the Event Dispatch Thread (EDT), which is why you should use the invokeLater.
99% of the time you won't have a problem, but when you do it probably will be random and you will have a hard time debugging the problem. So get in the habbit of creating Swing components properly and save yourself some grief.
Read the section from the Swing tutorial on Concurrency for more information.
- 02-08-2010, 06:23 AM #3
Member
- Join Date
- Dec 2009
- Posts
- 68
- Rep Power
- 0
have a look at this sir - Threads and Swing
- 02-08-2010, 07:14 AM #4
Senior Member
- Join Date
- Oct 2009
- Location
- California,US
- Posts
- 201
- Rep Power
- 4
thats a nice question so after some research i found this article hope it helps you
Threading with Swing
Threading with Swing: SwingUtilities.invokeLater
- 02-08-2010, 10:11 PM #5
Similar Threads
-
what is SwingUtilities.invokeLater(new Runnable())
By sivakumar_sakam in forum AWT / SwingReplies: 3Last Post: 05-06-2009, 04:47 AM -
Use of swingutilities.invokeLater
By neha_negi in forum AWT / SwingReplies: 2Last Post: 09-19-2008, 02:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks