Adding a GUI to your plugin
Just as we did while developing macros, there is a way to add a user interface to your plugin. This will allow us to ask the user for input regarding specific parameters that your code will use before running. This is done through methods of the
GenericDialog
class. Consider the following example, which will also introduce other concepts:
import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.filter.*; public class Dialog_Example implements PlugInFilter { ImagePlus imp; boolean dialogCanceled = false; int radius = 3; int filterType; public int setup(String arg, ImagePlus imp) { this.imp = imp; return DOES_ALL; } public void run(ImageProcessor ip) { doDialog(); if (dialogCanceled) return; RankFilters rf = new RankFilters(); rf.rank(ip, radius, filterType); } private void doDialog() { GenericDialog gd = new GenericDialog("Dialog example"...