import ij.*;
import ij.gui.*;
import ij.plugin.*;
import java.awt.event.*;

public class Button_Example implements PlugIn, ActionListener {

   public void run(String arg) {
       GenericDialog gd = new GenericDialog("AddButton Example");
       gd.addMessage("Press button to invert the active image. This\n"
          + "example requires ImageJ 1.53k18 or newer.");
       gd.setInsets(20, 80, 10);
       gd.addButton("Invert Image", this);
       gd.showDialog();
   }

   public void actionPerformed(ActionEvent e) {
      IJ.run("Invert");
   }

}
