Using SwingUtilities.invokeLater()

Chapter 9 - Threads and Swing

Java Thread Programming
Paul Hyde
  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


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net