|
The event dispatching thread (EDT) is a background thread used in Java to process events from the Abstract Windowing Toolkit (AWT) graphical user interface event queue. These events are primarily update events that cause user interface components to redraw themselves, or input events from input devices such as the mouse or keyboard. The AWT uses a single-threaded painting model in which all screen updates must be performed from a single thread. The event dispatching thread is the only valid thread to update the visual state of visible user interface components. Updating visible components from other threads is the source of many common bugs in Java programs that use Swing. A thread in computer science is short for a thread of execution. ...
Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ...
The Abstract Windowing Toolkit (AWT) is Javas platform_independent windowing, graphics, and user_interface widget toolkit. ...
PUI redirects here. ...
An event queue is a software queue that is used to process a sequence of inputs, typically from the user. ...
Software component representations: above the representation used in UML, below the representation commonly used by Microsofts COM objects. ...
A number of devices, called input devices, are used for entering data into a machine, typically a computer. ...
An abstract model (or conceptual model) is a theoretical construct that represents physical, biological or social processes, with a set of variables and a set of logical and quantitative relationships between them. ...
A software bug is an error, flaw, mistake, failure, or fault in a computer program that prevents it from behaving as intended (e. ...
A computer program is a collection of instructions that describe a task, or set of tasks, to be carried out by a computer. ...
Example Swing widgets in Java 5. ...
Executing code in the EDT
Other application threads can execute code in the event dispatching thread by defining the code in a Runnable object and pass it to the SwingUtilities helper class or to the EventQueue. Two methods of these classes allow synchronous (SwingUtilities.invokeAndWait(Runnable) or EventQueue.invokeAndWait(Runnable)) and asynchronous (SwingUtilities.invokeLater(Runnable) or EventQueue.invokeLater(Runnable)) code execution from the EDT. The method invokeAndWait() should never be called from the event dispatching thread—it will throw an exception. The method SwingUtilities.isEventDispatchThread() or EventQueue.isEventDispatchThread() can be called to determine if the current thread is the event dispatching thread. Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of some condition that changes the normal flow of execution. ...
Another solution for executing code in the EDT is using the worker design pattern. The SwingWorker class, developed by Sun Microsystems, is an implementation of the worker design pattern, and as Java 6 is part of standard Swing distribution. The open source project Foxtrot provides another synchronous execution solution similar to SwingWorker. SwingWorker is a popular utility class developed by Sun Microsystems for the Swing library of the Java programming language. ...
Sun Microsystems, Inc. ...
See also The Abstract Windowing Toolkit (AWT) is Javas platform_independent windowing, graphics, and user_interface widget toolkit. ...
Example Swing widgets in Java 5. ...
External links |