Login  Register

Re: Swing Java components in ImageJ plugin frames?

Posted by dscho on May 12, 2009; 8:16am
URL: http://imagej.273.s1.nabble.com/Swing-Java-components-in-ImageJ-plugin-frames-tp3692563p3692569.html

Hi,

On Tue, 12 May 2009, Simon Andrews wrote:

> 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.

Just that it does not display properly, defeating the purpose of the
exercise.

> 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.

Care to post your solution for the benefit of others (including me)?

Ciao,
Dscho