Re: Java repaint question - can ImageJ be updated to swing components and images?
Posted by
simon andrews (BI) on
Jun 23, 2008; 2:53pm
URL: http://imagej.273.s1.nabble.com/Java-repaint-question-tp3695800p3695803.html
On 23 Jun 2008, at 15:43, Jon Harman wrote:
> Hi,
>
> Wayne and others have suggested that a solution to my repaint
> problem is 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.
>
> I agree that having to know both AWT and swing intricacies is a
> pain, 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.
There are all kinds of gotchas with mixing AWT and swing. Try for
instance embedding an AWT canvas into a JScrollPane and watch what
happens!
In the application I developed (
http://www.bioinformatics.bbsrc.ac.uk/
projects/focalpoint/) I had all kinds of problems because I was
embedding AWT based ImageCanvas objects into a Swing based layout. I
ended up fixing this by making my own version of ImageCanvas which
extended JPanel rather than Canvas. You actually need very few
changes to make this work and everything ran much more smoothly
afterwards.
Simon.