-1

I want to set up an own programm using ImageJ as a library. So this will not going to be a plugin.

The user can open an image and then mark a spot with the point selection tool provided by ImageJ. When the user does this I want my measurements to happen around that point.

I already have a working programm, but the user has to click an extra button after selecting the desired point to start the measurement.

To provide an easy and fast usage I want the action to be happen right after selecting the point. Therefore I want to register a MouseListener. My question is: Where is the code that implements the point selection tool? And where can I register my MouseListener?

Thanks in advance.

  • What have you done so far? Here, you're supposed to show some significant effort and some understanding of the problem at hand. Usually, questions like 'How can I...?' will not be met with a lot of attention here. – likeitlikeit Jul 20 '13 at 20:43
  • I implemented a MouseListener, all the actions which should take place when the mouse clicks on the image, a GUI to display the results of measurements. I did not want to paste any code, because this would not help at all. I just want a hint where I can register the Listener in the ImageJ enviroment. Also I searched through the whole toolbar class provided my ImageJ and all the tools. I also tried the Listener Class provided by ImageJ, but it only displays mouse events on the toolbar. – user2599141 Jul 20 '13 at 21:09
  • Have you had a look at [this](http://stackoverflow.com/questions/6735795/java-how-to-add-a-listener-in-imagej-plugin?rq=1)? – likeitlikeit Jul 21 '13 at 13:33
  • Thanks! I have seen it before, but I did not pay close attention to it. – user2599141 Jul 21 '13 at 21:25

1 Answers1

1

Thanks to the last comment! I have seen it before, but I did not pay close attention to it.

For Everybody who encounters this issue:

The method show(String) in the ImagePlus class creates a new StackWindow. Right after that you can use:

 for(Object o: win.getComponents()){

(Or only win.getComponents()[0] if you know that there will be only one.

The first Object I get there is a ImageCanvas. So you can cast your Object o to a ImageCanvas and add you MouseListener there. With an anonymous class for example. Or maybe modify the ImagePlus Constructor to give a certain MouseListener when needed if you write your own standalone programm and just using ImageJ as a Bib.