how to make pictures in progress show

W

wnstnsmith

Dear all,

Perhaps this is a stupid question, but I cannot find the answer, so please
help:

In a java-application (not an applet), a series of pictures is processed. In
one corner of the application window there is a jpanel PEEP which should
show each picture as it is in the works, just to make the user happy that
the work is indeed being done.
The problem is that my picutres are duly processed, only the PEEP panel is
not repainted for each new picture that goes into the mill. Instead, it is
only repainted at the end of the whole loop, showing the last processed
picture.
Yes, the repaint instruction is in the loop, like this:

void process(img[] series) {
for (int i = 0; i < series.length; i++) {
PEEP.setPicture (series); //this puts the picture in PEEP
PEEP.repaint();
doWhatIsNeededWith(series);
}
}

what's wrong? tia.

WS
 
D

David Zimmerman

Thanks, but yes, I'm doing it from an event, i.e. in response to a
buttonclick. (indeed, the button stays "pressed" all the time, that's
another thing I don't much like but don't know how to get around).
Second, a lot is done to these pics, so the process is quite slow. One would
expect there to be ample time for the system to update the window.

WS

T\The event thread is the one that will draw your changes and draw the
button unpressed. If your using the event thread for your own nefarious
purposes, it can't do any of those things it's suipposed to do. You need
to do your stuff in a seperate thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top