| ||||
Copyright 1999 Sams Publishing |
|
Summary |
In this chapter, you saw how it is important that the event thread be the only thread that makes direct modifications to Swing components after they have been added to a visible container. The SwingUtilities.invokeAndWait() and SwingUtilities.invokeLater() methods provide a mechanism for any thread to put a block of code onto the event queue. When the event thread gets to the block of code, it executes it and safely makes changes to Swing components. Using these tools, threads were added to components to provide animation capabilities. Additionally, a worker thread was able to take the results of a long-running search and safely update the graphical interface of an application. |
| |||
Toc |