Change ImageJ PopupMenu from Java

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

Change ImageJ PopupMenu from Java

jumpfunky
Hello community!

I wondering if it is possible to modify the popup menu (shown in an
imagej image window) by a java imagej plugin.

I've google it, but I found only the way using the startup macros.

I have tried to disable it and add my own PopupMenu, but that doesnt
work:
ImageCanvas ic = (ImageCanvas)imp.getWindow().getComponent(0);
ic.disablePopupMenu(true);
PopupMenu ab = new PopupMenu("ab");
ab.add(new MenuItem("abc"));
ic.add(ab);

Cheers,
Thorsten

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

Re: Change ImageJ PopupMenu from Java

Jan Eglinger
Hi Thorsten,

On 18.07.2014, 1:00 PM, Thorsten Wagner wrote:
> I wondering if it is possible to modify the popup menu (shown in an
> imagej image window) by a java imagej plugin.

I guess you could use the static method

     Menus.getPopupMenu()

of the ij.Menus class [1] to get the Menu, then use the

     add(String label)
or
     insert(String label, int index)

methods to modify it [2].

Best,
Jan

[1]:
http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/index.html?ij/Menus.html
[2]:
http://docs.oracle.com/javase/6/docs/api/index.html?java/awt/Menu.html


>
> I've google it, but I found only the way using the startup macros.
>
> I have tried to disable it and add my own PopupMenu, but that doesnt
> work:
> ImageCanvas ic = (ImageCanvas)imp.getWindow().getComponent(0);
> ic.disablePopupMenu(true);
> PopupMenu ab = new PopupMenu("ab");
> ab.add(new MenuItem("abc"));
> ic.add(ab);
>
> Cheers,
> Thorsten

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

Re: Change ImageJ PopupMenu from Java

jumpfunky
That works!

Thanks,
Thorsten

Am Freitag, den 18.07.2014, 15:10 +0200 schrieb Jan Eglinger:

> Hi Thorsten,
>
> On 18.07.2014, 1:00 PM, Thorsten Wagner wrote:
> > I wondering if it is possible to modify the popup menu (shown in an
> > imagej image window) by a java imagej plugin.
>
> I guess you could use the static method
>
>      Menus.getPopupMenu()
>
> of the ij.Menus class [1] to get the Menu, then use the
>
>      add(String label)
> or
>      insert(String label, int index)
>
> methods to modify it [2].
>
> Best,
> Jan
>
> [1]:
> http://jenkins.imagej.net/job/ImageJ1-javadoc/javadoc/index.html?ij/Menus.html
> [2]:
> http://docs.oracle.com/javase/6/docs/api/index.html?java/awt/Menu.html
>
>
> >
> > I've google it, but I found only the way using the startup macros.
> >
> > I have tried to disable it and add my own PopupMenu, but that doesnt
> > work:
> > ImageCanvas ic = (ImageCanvas)imp.getWindow().getComponent(0);
> > ic.disablePopupMenu(true);
> > PopupMenu ab = new PopupMenu("ab");
> > ab.add(new MenuItem("abc"));
> > ic.add(ab);
> >
> > Cheers,
> > Thorsten
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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