ImageListener

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageListener

Phase GmbH
Hello

I use ij.jar as a library in an Swing Java (JFrame) application and have a problem with Image Listener Interface in the situation described below:


In this application a separate Thread is created. Before the thread is started, a new image window is generated and displayed by using the ImagePlus class. The variable holding the ImagePlus object is declared globally in the Thread class. The ImageListener Interface is also added to the Thread class. The application runs without any error and the desired image window is displayed. However, when closing the image window by clicking to the cross button in the caption bar or by calling the close() method of the ImagePlus variable,  the Image Window is closed but the imageClosed method of the ImageListener interface is not called. The ImageListener however seems to work somehow, since filling the image window with new contents generates the expected call to the imageUpdated method.


Any idea?

Regards

Christian Kreutzfeldt

--
 
+++++++++++++++++++++++++++++
PHASE GmbH
Bluecherstr. 2 , 23564 Luebeck, Germany

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageListener

Barry DeZonia
Can you share some code? It will be easier to diagnose. For instance
showing the declaration and registration of the ImageListener. It sounds
like you're attaching to a Thread that may terminate before the ImageWindow
closes.


On Mon, Mar 18, 2013 at 4:56 AM, Christian Kreutzfeldt <[hidden email]
> wrote:

> Hello
>
> I use ij.jar as a library in an Swing Java (JFrame) application and have a
> problem with Image Listener Interface in the situation described below:
>
>
> In this application a separate Thread is created. Before the thread is
> started, a new image window is generated and displayed by using the
> ImagePlus class. The variable holding the ImagePlus object is declared
> globally in the Thread class. The ImageListener Interface is also added to
> the Thread class. The application runs without any error and the desired
> image window is displayed. However, when closing the image window by
> clicking to the cross button in the caption bar or by calling the close()
> method of the ImagePlus variable,  the Image Window is closed but the
> imageClosed method of the ImageListener interface is not called. The
> ImageListener however seems to work somehow, since filling the image window
> with new contents generates the expected call to the imageUpdated method.
>
>
> Any idea?
>
> Regards
>
> Christian Kreutzfeldt
>
> --
>
> +++++++++++++++++++++++++++++
> PHASE GmbH
> Bluecherstr. 2 , 23564 Luebeck, Germany
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageListener

Michael Schmid
Hi Christian,

ImageListeners should get their events from the corresponding ImagePlus. The 'imageClosed' is fired if the ImagePlus.flush method gets called. The ImageWindow of ImageJ (AWT) does this in its close() method. If you have the ImagePlus not inside an ImageWindow of ImageJ, you have to call the flush() method for the ImagePlus in the close() method of the window containing the ImagePlus.

For debugging, you can use the Image_Listener test program at
  http://rsb.info.nih.gov/ij/plugins/image-listener.html

It should report all ImageListener events.


Michael
________________________________________________________________

On Mon, Mar 18, 2013 at 4:56 AM, Christian Kreutzfeldt <[hidden email] wrote:

> Hello
>
> I use ij.jar as a library in an Swing Java (JFrame) application and have a
> problem with Image Listener Interface in the situation described below:
>
>
> In this application a separate Thread is created. Before the thread is
> started, a new image window is generated and displayed by using the
> ImagePlus class. The variable holding the ImagePlus object is declared
> globally in the Thread class. The ImageListener Interface is also added to
> the Thread class. The application runs without any error and the desired
> image window is displayed. However, when closing the image window by
> clicking to the cross button in the caption bar or by calling the close()
> method of the ImagePlus variable,  the Image Window is closed but the
> imageClosed method of the ImageListener interface is not called. The
> ImageListener however seems to work somehow, since filling the image window
> with new contents generates the expected call to the imageUpdated method.
>
>
> Any idea?
>
> Regards
>
> Christian Kreutzfeldt

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html