Login  Register

Re: Swing Java components in ImageJ plugin frames?

Posted by simon andrews (BI) on May 12, 2009; 7:35am
URL: http://imagej.273.s1.nabble.com/Swing-Java-components-in-ImageJ-plugin-frames-tp3692563p3692568.html

On 12 May 2009, at 00:32, Johannes Schindelin wrote:

> The problem is that you cannot add an ImageCanvas to any Swing layout.

Sure you can.  There are gotchas with mixing heavyweight (AWT) and  
lightweight (Swing) components, but it's certainly not forbidden.  You  
can add anything which derives from Component to a Swing layout, which  
covers ImageCanvas.

Someone else posted a pointer to a list of workrounds for common  
problems, but one other option which I've used is to create a swing  
based version of ImageCanvas.  There are very few changes required to  
turn ImageCanvas into JImagePanel and then everything plays really  
nicely with the rest of Swing.  Probably overkill in your case, but in  
the right situation it can be the best solution.

Simon.
--
Simon Andrews PhD
Babraham Bioinformatics
www.bioinformatics.bbsrc.ac.uk
[hidden email]
+44 (0) 1223 496463