Call plugin UI as a context menu in FIJI

I have a FIJI plugin with GUI, and I want to be able to call its GUI by a combination of keys; thus it works as a sort of context menu.

This is how my (poor) understanding sees it.

  • The plugin idles in the background of FIJI/ImageJ with invisible JFrame (it has been started either manually, or run automatically at the start of FIJI).
  • There is a combination of keys (say, ctrl+shift+A) that should be registered in FIJI. When I hit them within focused FIJI window - FIJI calls a method of my plugin.
  • This method makes plugin’s JFrame visible (sort of context menu); thus the plugin can listen to my clicks
  • I click on menu items, the plugin runs respective commands, disappears, and again idles in the background until I hit the key combination.

Is it possible? I thought about overriding the ImagePlus Window keylistener, but it seems destructive (if possible at all).
What platform in SciJava is the most suitable for that? I thought it should be a “Service”, but I cannot find any respective tutorial on that.


Hi dimersh
I modified the Plugin_Frame example to allow this:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.frame.*;

public class Hideable_Plugin_Frame extends PlugInFrame {
	public static boolean visible;
	public static TextArea ta = new TextArea(15, 50);

	public Hideable_Plugin_Frame() {
	public static String toggle(String s) {
		visible = !visible;
		return "";

After running this plugin once, you can the toggle frame visibility using a simple installed macro with a shortcut:

macro "toggle editor frame [t]"{
   call("Hideable_Plugin_Frame.toggle", "");


1 Like