Login  Register

Re: How to instantiate ImagePlus in an existing window ?

Posted by Albert Cardona on Jan 21, 2006; 6:52pm
URL: http://imagej.273.s1.nabble.com/How-to-use-jar-file-in-ImageJ-plugin-tp3703985p3703988.html

Andy,

Simply create the Image plus and DO NOT call show() on it.

If you plan to use it inside an AWT Component, then instantiate a new
ij.gui.ImageCanvas that contains the ImagePlus, and add that canvas to the
awt.Window or whatever awt component.

If you plan to use it inside a SWING JComponent, then extend a JPanel,
override the update(Graphics g) to call paint(g), and override paint(Graphics
g) to paint the awt.Image that you can get from the ImagePlus (or its
ImageProcessor) by calling my_image_plus.getImage() . Be sure to
setMinimumSize of the extended JPanel to the size of the ImagePlus.

The approach for SWING fixes lots of repainting problems when it has to
coexist with other SWING JComponent objects inside the same layout (awt
components are painted last, and over any other swing JComponent objects).


Hope it helps.

Albert

--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.pensament.net/java/
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com