Login  Register

Re: How to add an ActionListener to the ImageJ menu

Posted by Wayne Rasband on Aug 18, 2007; 11:35pm
URL: http://imagej.273.s1.nabble.com/How-to-add-an-ActionListener-to-the-ImageJ-menu-tp3698587p3698588.html

Plugins can implement the ImageListener interface to detect when  
image windows are opened or closed. There is an example at <http://
rsb.info.nih.gov/ij/plugins/image-listener.html>.

-wayne

On Aug 18, 2007, at 12:12 PM, Piotr Wendykier wrote:

> Hello,
>
> I'm trying to add an ActionListener to the ImageJ menu, but my code
> does not work:
>
> MenuBar menuBar = IJ.getInstance().getMenuBar();
> Menu menu = menuBar.getMenu(0);
> menu.addActionListener(new ActionListener() {
>     public void actionPerformed(ActionEvent e) {
>         //TODO
>     }
> });
>
> It looks like the only ActionListener that is added to the menu is  
> ij.ImageJ.
> In my plugin I want to respond to ImageJ menu events (in particular, I
> need to know when new window was opened).
>
> Thanks,
>
> Piotr Wendykier