|
-
May 5th, 2000, 08:52 PM
#1
Using animated image in a separate thread
I am trying to get an animated image (icon) to display while my program is doing a search.
I started by launching the search on a separate thread, while the icon (an animated gif) is displayed on the main thread. The problem is that as soon as the animation starts, the user is able to continue accessing controls within the panel in the main thread (ie press buttons, enter data into fields, etc.), which is unaceptable. I tried to disable the main panel, but that does not seem to disable the components within the panel, and I don't want to have to disable each component individually.
I then tried the opposite. That is to launch the animation in the new thread. However, it seems that the animation will only 'run' when there is nothing happening on the main thread (ie main thread is idle), which means the animation only starts after the search is executed, and the program is again waiting for user input.
As a simple example, if you create a JFC applet, add a label, and put an icon on the label, then then put the program to sleep for a few seconds, the label & icon will only be displayed after the end of the sleep time. It seems as though the screen will only be painted while there is nothing else going on. There is no way to get the screen to repaint while the main thread is processing. (sample code below)
If anyone knows how (a) I can display my animated icon from a secondary thread, while the main thread is processing;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|