Login  Register

Re: Java repaint question

Posted by simon andrews (BI) on Jun 23, 2008; 8:50am
URL: http://imagej.273.s1.nabble.com/Java-repaint-question-tp3695800p3695804.html

 

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On
> Subject: Java repaint question
>
> Hi,
>
> In my plugin I want to cycle through a set of enhancements.  
> My code to do this is inside of the actionPerformed routine
> for the button press in my customWindow.
> I have tried lots of  things: repaint, repaintWindow, updateImage...
> (for the imagePlus or the window or the custom canvas) but
> the image refuses to update until the code exits the
> actionPerformed routine.  Is there a way I can get it to
> repaint the image without leaving the button press routine?

Since your ActionPerformed method is still active when you want the
update to happen you'd probably have to structure your plugin so that
your button push is in a separate thread and then let that thread sleep
after issuing the update so that the original ImageJ thread gets a
chance to process the request.

For getting the image to update I use a validate() followed by a
repaint(), which seemed to be the miniumum necessary to force an update
to a custom canvas (though I suspect it depends on exactly what you're
changing).

Simon.