Results 1 to 4 of 4
- 03-12-2009, 08:26 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
How to send event from thread to GUI?
I have a program with multiple threads plus the thread for the Swing frame.
The frame contains a text field.
How does another thread tell the Swing thread to change the text?
I assume the preferred way is to give an event to the text field component with the new text. Correct? Sounds easy, but I can't figure out how to do it. :o
-
You use SwingUtilities to help you queue method calls on the EDT:
Java Code:SwingUtilities.invokeLater(new Runnable() { public void run() { // .. the method(s) you want to call on Swing widgets } });
- 03-12-2009, 11:24 PM #3
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
Thanks. Looks like that will do it.
Later: OK, it's working in my program now. Onward and upward, one inch at a time...Last edited by mikeeve; 03-13-2009 at 12:49 AM.
-
Similar Threads
-
Difference between Thread.yield() and Thread.sleep() methods
By Nageswara Rao Mothukuri in forum New To JavaReplies: 12Last Post: 07-30-2010, 05:37 PM -
passing a value from parent thread to child thread
By sachinj13 in forum Threads and SynchronizationReplies: 7Last Post: 09-07-2008, 09:06 PM -
data from the main/GUI thread to another runnin thread...
By cornercuttin in forum Threads and SynchronizationReplies: 2Last Post: 04-23-2008, 10:30 PM -
If JNI thread call the java object in another thread, it will crash.
By skaterxu in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 07:02 AM


LinkBack URL
About LinkBacks

Bookmarks