Login  Register

Problem with using Radio Buttons in a plugin when called from a macro

Posted by Stein Rørvik on Apr 17, 2019; 5:01pm
URL: http://imagej.273.s1.nabble.com/Problem-with-using-Radio-Buttons-in-a-plugin-when-called-from-a-macro-tp5022095.html

Hello,

I see some strange behaviour with the use of Radio Buttons in plugins.
The plugins behave correctly when called from the GUI, but not when called from a macro.

My plugin is a PlugInFilter, but the exact problem can be reproduced by the simple PlugIn example below.

The macro recorder records this, when selecting button 3:

run("Radio Buttons", "cars=Maserati");

If you run this one-line macro, the first showMessage is shown correctly but not the second one.
It is not called at all when using a macro. From the GUI it is called correctly.

Does anyone have an idea what is wrong here?

plugin code:
----------------------------------------------------------------------------------------
import ij.IJ;
import ij.gui.*;
import ij.plugin.*;

public class Radio_Buttons implements PlugIn {
                String mycar;
                String[] cars = {"Ford", "Citroen", "Maserati", "Volvo"};

                public void run(String arg) {
                               showDialog();
                               IJ.log("Cars: "+ mycar);
                               IJ.showMessage("The car you are driving is a " + mycar);
                               if (mycar == "Ford") { IJ.showMessage("That is an American car"); }
                               if (mycar == "Citroen") { IJ.showMessage("That is a French car"); }
                               if (mycar == "Maserati") { IJ.showMessage("That is an Italian car"); }
                               if (mycar == "Volvo") { IJ.showMessage("That is a Swedish car"); }
                }

                void showDialog() {
                               GenericDialog gd = new GenericDialog("Select Car");
                               gd.addRadioButtonGroup("Cars", cars, 4, 1, "Ford");
                               gd.showDialog();
                               mycar = gd.getNextRadioButton();
                }
}
----------------------------------------------------------------------------------------


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