|
| ||||||||||
| Tags: invokelater, java, swing, utilities |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| What is SwingUtilities.invokeLater(Runnable) method in Java?
|
|
#2
| |||
| |||
| Re: What is SwingUtilities.invokeLater(Runnable) method in Java?
The static utility method invokeLater(Runnable) is intended to execute a new runnable thread from a Swing application without disturbing the normal sequence of event dispatching from the Graphical User Interface (GUI). The method places the runnable object in the queue of Abstract Windowing Toolkit (AWT) events that are due to be processed and returns immediately. The runnable object’s run() method is only called when it reaches the front of the queue. The deferred effect of the invokeLater(Runnable) method ensures that any necessary updates to the user interface can occur immediately, and the runnable work will begin as soon as those high priority events are dealt with. The invoke later method might be used to start work in response to a button click that also requires a significant change to the user interface, perhaps to restrict other activities, while the runnable thread executes. |
|
#3
| |||
| |||
| Re: What is SwingUtilities.invokeLater(Runnable) method in Java?
If possible also provide me the Example of SwingUtilities.invokeLater(Runnable) method. Thanks |
|
#4
| |||
| |||
| Re: What is SwingUtilities.invokeLater(Runnable) method in Java?
I will explain you the example, how to implement the SwingUtilities.invokeLater(Runnable) method in the program. Code: SwingUtilities.invokeLater(
new Runnable(){
public void run(){
outputArea.append(messageToDisplay);
}
}
); |
|
#5
| |||
| |||
| Re: What is SwingUtilities.invokeLater(Runnable) method in Java?
what does invokeLater actually do, along with the nested method within it. |
|
#6
| |||
| |||
| Re: What is SwingUtilities.invokeLater(Runnable) method in Java?
The Swing Library is not thread safe, which means that only one thread may create or modify swing objects. This is the AWT Event thread. Whenever Swing calls a listener method, it is executed on the AWT Event thread, so you may modify Swing objects here. InvokeLater causes Swing to run a given runnable when it can on the AWT Event thread. You should use invokeLater any time you want to modify a Swing object outside of a listener method. Hope this makes you clear with Swing and AWT. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "What is SwingUtilities.invokeLater(Runnable) method in Java?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Method replaceAll in java | TechGate | Software Development | 5 | 24-02-2010 12:06 AM |
| SwingUtilities class of java | Owen Fernandes | Software Development | 5 | 12-02-2010 07:23 AM |
| What is method overriding and method overloading in java | beelow | Software Development | 3 | 17-11-2009 07:20 AM |
| Problem with my java method | manjava | Software Development | 3 | 17-11-2009 05:15 AM |
| Java: How can I call one method in another method? | biohazard 76 | Software Development | 3 | 16-07-2009 07:12 PM |