http://imagej.273.s1.nabble.com/Java-repaint-question-tp3695800p3695802.html
to create a new thread using code similar to the image processing demo.
I have done that and it works.
I use two panels in my plugin. An old one done in AWT and a new one
using swing. I can switch between the two without problems.
but I have not had any problems with my swing panel. It exists in a
CustomWindow in a CustomCanvas and uses an ImagePlus. I originally
started with the Panel_Window demo then changed the panel to swing. So
as far as my experience goes ImageJ is compatible with swing.
> Jon
>
> I had a similar problem, and I'm not positive its the same problem but
> what I was doing was customizing an ImageJ ImageWindow with an ImagePlus
> displayed and put swing components into it. The problem was that ( for
> whatever reason :'( ) ImageJ Windows are based on the historically older
> ( and by now outdated ) AWT package in JAVA that takes care of GUI
> programming. The way I was doing it at least you can't mix swing and
> AWT. I think you can include AWT in swing but not swing with a base
> component ( the ImageWindow ). What I did was just start from scratch
> and make my custom window done completely in swing and it wasn't too
> bad. If you need the functionality of the ImagePlus or ImageProcessor
> classes you can store your images in an ImagePlus class and then just
> export the image itself for display in your all swing Window. The
> ImageProcessor classes have a createImage() method that puts your
> ImagePlus back into a JAVA image. Since ImageJ is based on AWT , these
> methods will return AWT images. This may be fine for your application
> and AWT images can be displayed easily in a custom swing based window (
> usually through a AWT canvas thats added ultimately to a JFrame class ).
> If you need functionality for a BufferedImage instead ( it allows you to
> access pixels as a raster, an array of pixel values ) then you have to
> beat around the bush a bit more and to a trick to convert an Image to a
> BufferedImage. This is explained below from
>
http://en.allexperts.com/q/Java-1046/Image-BufferedImage-Conversion.htm>
> the easiest way to make a usable
> BufferedImage is to create a blank buffered
> image and then draw the old Image into it
> using a Graphics. I know it sounds lame, but
> that is the only really portable way. You can
> see an example and explanation here:
>
http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Supplements/Chapter11/...
> <
http://www.particle.kth.se/%7Elindsey/JavaCourse/Book/Part1/Supplements/Chapter11/bufferedImage.html>
>
>
> What I did instead of converting to BufferedImage, is if you are reading
> image files off of your computer, just load them as BufferedImages in
> the first place,
> then its trivial to cast in the other direction using the typical JAVA
> casting:
>
> BufferedImage bImage;
> // then load it from file
> Image AWTImage = (Image) bImage;
>
> then you use the AWT Image to create you ImagePlus object and access
> ImageJ's functionality
> If your image is changing a lot its pretty indirect.
> What really should have been done is to write ImageJ using swing to
> begin with
> *I don't know when ImageJ was first concieved
> but it wouldn't be terribly hard to rewrite the Image classes and
> ImageWindow classes in the more modern and vastly superior JAVA swing
> package.*
>
> Hope that helps
> Doug Snyder
>
>
>
>
> Jon Harman wrote:
>> 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?
>>
>> Jon
>>
>