Login  Register

Re: Change ImageJ PopupMenu from Java

Posted by Jan Eglinger on Jul 18, 2014; 1:10pm
URL: http://imagej.273.s1.nabble.com/Change-ImageJ-PopupMenu-from-Java-tp5008822p5008824.html

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