Work/paint/thread mixing

From: TheDD (pas.d_at_email.com)
Date: 12/21/03


Date: Sun, 21 Dec 2003 12:00:31 +0100

Hello all,

I'm developping an applet which upload a file on a ftp server.

On the applet i have one "Go" button. And when the user click on it, it
starts the upload.

For painting/refreshing/drawing problem, i create a thread for the upload.

But i also have a progress bar on the Applet Frame. So i don't know how to
mix that.

| GUI thread | | upload thread |
|->window need refresh | | while (1) { |
|->progress bar value changed| | applet.progressbar.setValue(); |
| recently enough | | bos.write(); |
| | | } |

1/ I would like to "invalidate" the progress bar area when i change its
value. But calling applet.jProgresseBar.setValue() from the upload thread
seems ugly because i don't know what can happen if the gui thread is
already re-painting (is it thread safe?).
2/ I would like that the applet is repainted when some window go over the
browser window and then is removed (which is not the case actually).
3/ I don't want to manually call paint() each time the jprogressbar value
change, beacause i think it's utgly. I just want to warn the applet that
for the next draw (caused by time or sooner by something else), it take the
progress bar value change.

If somebody can tell me what is the best way to do that.

-- 
TheDD