Lost regarding RadioButton problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Lost regarding RadioButton problem

gankaku
Hi all,

I just started writing a plugin containing a dialog with a radio button group, but Java tells me that it can't find the method and due to my still very rudimentary general knowledge in Java, I am getting nuts in finding out, why this method is not found.
potentially I missed to import some important classes or something like that.
Potentially, someone of you guys directly spots an obvious mistake, I am simply ignoring.

Thanks a lot for the look into the hay stack ;-)
Jan

The code (so far):

import java.awt.*;
import ij.*;
import ij.plugin.frame.PlugInFrame;
import ij.plugin.filter.*;
import ij.process.*;
import ij.gui.DialogListener;
import ij.gui.GenericDialog;
import ij.gui.*;



public class Adaptive_Filter implements PlugInFilter {
       
ImagePlus imp;

        private String[] labels = new String[] {"median", "mean" };
       
        public int setup(String arg, ImagePlus imp) {
        this.imp = imp;
        return DOES_8G+DOES_16;
    }

        public void run(ImageProcessor orig) {
                int w = orig.getWidth();
                int h = orig.getHeight();
                ImageProcessor copy = orig.duplicate();

                GenericDialog init = new GenericDialog("Filter setup");
                        init.addNumericField("Radius (pixels):", 1, 0);
                        init.addRadioButtonGroup(null, labels, 1, 2, "median");
                        init.showDialog();
                        if (init.wasCanceled()) {
                        return;
                        }
                        int radius = (int) init.getNextNumber();
                        String useMethod = init.getNextRadioButton();

        }
...... to be continued......
}


The error messages:

cannot find symbol
symbol  : method addRadioButtonGroup(<nulltype>,java.lang.String[],int,int,java.lang.String)
location: class ij.gui.GenericDialog
                        init.addRadioButtonGroup(null, labels, 1, 2, "median");
                            ^

cannot find symbol
symbol  : method getNextRadioButton()
location: class ij.gui.GenericDialog
                        String useMethod = init.getNextRadioButton();
                                               ^

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

AJBell
Hi gankaku,

The problem is that, as far as I am aware, there is no RadioButtonGroup class in awt. I may be wrong on that, and if so someone will correct me. Instead you can use CheckboxGroup. In awt the checkbox class does both checkboxes and radiobuttons. See code below.

Andrew

public class Filter_Plugin implements PlugInFilter {
        ImagePlus imp;

        private String[] labels = new String[] {"median", "mean" };
       
        public int setup(String arg, ImagePlus imp) {
        this.imp = imp;
        return DOES_8G+DOES_16;
    }

        public void run(ImageProcessor orig) {
                int w = orig.getWidth();
                int h = orig.getHeight();
                ImageProcessor copy = orig.duplicate();

                GenericDialog init = new GenericDialog("Filter setup");
                        init.addNumericField("Radius (pixels):", 1, 0);

                CheckboxGroup grp = new CheckboxGroup();
                for(int i=0;i<3;i++){
                        Checkbox box = new Checkbox("Box "+i,grp,false);
                        init.add(box);
                }
                   
                        init.showDialog();
                        if (init.wasCanceled()) {
                        return;
                        }
            }

}

gankaku wrote
Hi all,

I just started writing a plugin containing a dialog with a radio button group, but Java tells me that it can't find the method and due to my still very rudimentary general knowledge in Java, I am getting nuts in finding out, why this method is not found.
potentially I missed to import some important classes or something like that.
Potentially, someone of you guys directly spots an obvious mistake, I am simply ignoring.


ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

gankaku
In reply to this post by gankaku
Hi Andrew,

Thanks for the fast reply and the tipp.
I also read earlier that RadioButtons do not exist in the GenericDialog class. But when you check the API the method is present there and it can be also invoked using the macro language, so it actually should be possible to include them but I might be wrong.

cheers,
Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

Michael Schmid
In reply to this post by gankaku
On Aug 14, 2013, at 11:13, Jan Brocher - BioVoxxel wrote:

> I just started writing a plugin containing a dialog with a radio button group, but Java tells me that it can't find the method

addRadioButtonGroup() and getNextRadioButton() were added to the GenericDialog class in ImageJ 1.47r.
Maybe you have an older version?

Use Help>Update ImageJ (for this, you need write access to the ImageJ directory; on Mac OSX also write access to the contents of ImageJ.app is needed)

Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

gankaku
In reply to this post by gankaku
Hi Michael,

Thanks for your reply.
I had version v1.48a and also tried the daily build (v1.48b10).
So, unfortunately rather no version problem. But at least I know now that theoretically it should/can work ;-)

cheers,
Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

gankaku
In reply to this post by gankaku
The origin of the non-functional addRadioButtonGroup method was actually that I used it in Fiji with the respective ImageJ version.
In the pure ImageJ it seems to work. Sorry for the confusion!
Nevertheless, dous that mean, that Fiji does not support this method so far?
Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

Jan Eglinger
In reply to this post by gankaku
Dear Jan,

On 14.08.2013 11:13 AM, Jan Brocher - BioVoxxel wrote:
> I just started writing a plugin containing a dialog with a radio button group, but Java tells me that it can't find the method and due to my still very rudimentary general knowledge in Java, I am getting nuts in finding out, why this method is not found.
> potentially I missed to import some important classes or something like that.
> Potentially, someone of you guys directly spots an obvious mistake, I am simply ignoring.

Did you try with an empty String "" instead of null as first parameter
in your addRadioButtonGroup() method?
The following code works for me within Fiji:

// Save this as Bare_Plugin.java

import ij.IJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;

public class Bare_PlugIn implements PlugIn {
        @Override
        public void run(String arg) {
                GenericDialog gd = new GenericDialog("Test");
                String[] items = new String[3];
                items[0] = "First";
                items[1] = "Second";
                items[2] = "Third";
                gd.addRadioButtonGroup("Button", items, 3, 1, "First");
                gd.showDialog();
                IJ.log(gd.getNextRadioButton());
        }
}


Hope that helps,
Jan


>
> Thanks a lot for the look into the hay stack ;-)
> Jan
>
> The code (so far):
>
> import java.awt.*;
> import ij.*;
> import ij.plugin.frame.PlugInFrame;
> import ij.plugin.filter.*;
> import ij.process.*;
> import ij.gui.DialogListener;
> import ij.gui.GenericDialog;
> import ij.gui.*;
>
>
>
> public class Adaptive_Filter implements PlugInFilter {
>
> ImagePlus imp;
>
> private String[] labels = new String[] {"median", "mean" };
>
> public int setup(String arg, ImagePlus imp) {
>         this.imp = imp;
>         return DOES_8G+DOES_16;
>     }
>
> public void run(ImageProcessor orig) {
>        int w = orig.getWidth();
>        int h = orig.getHeight();
>        ImageProcessor copy = orig.duplicate();
>
> GenericDialog init = new GenericDialog("Filter setup");
> init.addNumericField("Radius (pixels):", 1, 0);
>                init.addRadioButtonGroup(null, labels, 1, 2, "median");
>                init.showDialog();
>                if (init.wasCanceled()) {
>                 return;
>                }
>                int radius = (int) init.getNextNumber();
>                String useMethod = init.getNextRadioButton();
>
> }
> ...... to be continued......
> }
>
>
> The error messages:
>
> cannot find symbol
> symbol  : method addRadioButtonGroup(<nulltype>,java.lang.String[],int,int,java.lang.String)
> location: class ij.gui.GenericDialog
>                init.addRadioButtonGroup(null, labels, 1, 2, "median");
>                    ^
>
> cannot find symbol
> symbol  : method getNextRadioButton()
> location: class ij.gui.GenericDialog
>                String useMethod = init.getNextRadioButton();
>                                       ^

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Lost regarding RadioButton problem

Peter Haub
Hi

I got on error message in Eclipse using your code line:
        private String[] labels = new String[] {"median", "mean" };

Changing this to
        String[] labels = new String[] {"median", "mean" };
fixed the problem.

Regards,
Peter

On 14.08.2013 13:12, Jan Eglinger wrote:

> Dear Jan,
>
> On 14.08.2013 11:13 AM, Jan Brocher - BioVoxxel wrote:
>> I just started writing a plugin containing a dialog with a radio button group, but Java tells me that it can't find the method and due to my still very rudimentary general knowledge in Java, I am getting nuts in finding out, why this method is not found.
>> potentially I missed to import some important classes or something like that.
>> Potentially, someone of you guys directly spots an obvious mistake, I am simply ignoring.
> Did you try with an empty String "" instead of null as first parameter
> in your addRadioButtonGroup() method?
> The following code works for me within Fiji:
>
> // Save this as Bare_Plugin.java
>
> import ij.IJ;
> import ij.gui.GenericDialog;
> import ij.plugin.PlugIn;
>
> public class Bare_PlugIn implements PlugIn {
> @Override
> public void run(String arg) {
> GenericDialog gd = new GenericDialog("Test");
> String[] items = new String[3];
> items[0] = "First";
> items[1] = "Second";
> items[2] = "Third";
> gd.addRadioButtonGroup("Button", items, 3, 1, "First");
> gd.showDialog();
> IJ.log(gd.getNextRadioButton());
> }
> }
>
>
> Hope that helps,
> Jan
>
>
>> Thanks a lot for the look into the hay stack ;-)
>> Jan
>>
>> The code (so far):
>>
>> import java.awt.*;
>> import ij.*;
>> import ij.plugin.frame.PlugInFrame;
>> import ij.plugin.filter.*;
>> import ij.process.*;
>> import ij.gui.DialogListener;
>> import ij.gui.GenericDialog;
>> import ij.gui.*;
>>
>>
>>
>> public class Adaptive_Filter implements PlugInFilter {
>>
>> ImagePlus imp;
>>
>> private String[] labels = new String[] {"median", "mean" };
>>
>> public int setup(String arg, ImagePlus imp) {
>>           this.imp = imp;
>>           return DOES_8G+DOES_16;
>>       }
>>
>> public void run(ImageProcessor orig) {
>>        int w = orig.getWidth();
>>        int h = orig.getHeight();
>>        ImageProcessor copy = orig.duplicate();
>>
>> GenericDialog init = new GenericDialog("Filter setup");
>> init.addNumericField("Radius (pixels):", 1, 0);
>>                init.addRadioButtonGroup(null, labels, 1, 2, "median");
>>                init.showDialog();
>>                if (init.wasCanceled()) {
>>                 return;
>>                }
>>                int radius = (int) init.getNextNumber();
>>                String useMethod = init.getNextRadioButton();
>>
>> }
>> ...... to be continued......
>> }
>>
>>
>> The error messages:
>>
>> cannot find symbol
>> symbol  : method addRadioButtonGroup(<nulltype>,java.lang.String[],int,int,java.lang.String)
>> location: class ij.gui.GenericDialog
>>                init.addRadioButtonGroup(null, labels, 1, 2, "median");
>>                    ^
>>
>> cannot find symbol
>> symbol  : method getNextRadioButton()
>> location: class ij.gui.GenericDialog
>>                String useMethod = init.getNextRadioButton();
>>                                       ^
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>

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