For the most part, Swing components are single-threaded. This can have some adverse affects if your code invokes a time-consuming operation. For example, your GUI components will wait until your operation is finished before repainting. The same holds true if you want to change the cursor to a wait cursor. One of the solutions which Sun recommends is to use a SwingWorker Thread. A Swing Worker thread is a thread which is spawned with the goal of performing the lengthy operation, rather than making the Swing thread handle it. This will allow your GUI components to repaint long before the time-consuming operation finishes.
For a more complete tutorial, please visit the 'How to use Threads' tutorial at Sun's website. There is also the SwingWorker.java class which you will need to subclass.
At a glance...
Swing Worker Thread
Please contact our Webmaster with questions or comments.
© Copyright 1998 Solutions Plus, Inc. All rights reserved.
This page is best viewed with IE 4.0 or higher
Cast your vote!