Re: GenericDialog Choice with units method

Posted by Kenneth Sloan-2 on
URL: http://imagej.273.s1.nabble.com/GenericDialog-Choice-with-units-method-tp5023727p5023730.html

I meant the choice VALUE - not the prompt.  You can’t do this with numeric
(or string) fields, do it’s more important to have a special location for
units for those fields, but choice values are strings determined by the
program and not altered by the user, so putting the units there makes sense.

I can also imagine cases where the various choice options have DIFFERENT
units.  Indeed, where it is precisely the units that are being selected.

That said, I agree that it would be nice to have a “units” parameter for
choices - if only for the sake of orthogonal design.

On Fri, Jul 17, 2020 at 11:15 CARL Philippe (LBP) <[hidden email]>
wrote:

> Indeed, and that is exactly what I have (= had) up to now (both for the
> NumericField as well as for the Choice)...
>
> ----- Le 17 Juil 20, à 18:01, Kenneth R Sloan [hidden email] a
> écrit :
>
> You could make the unit part of the choice string.
>
> On Fri, Jul 17, 2020 at 10:48 CARL Philippe (LBP) <
> [hidden email]>
> wrote:
>
> > Dear all,
> > Within a GenericDialog there are 3 methods for adding a NumericField, one
> > of them nicely giving the possibility to define the unit of the field
> > content:
> >                 void addNumericField(java.lang.String label, double
> > defaultValue, int digits, int columns, java.lang.String units)
> > Very unfortunately there is only one method for adding a Choice which
> > actually doesn't give the option for an unit entry:
> >                 addChoice(java.lang.String label, java.lang.String[]
> > items, java.lang.String defaultItem)
> > Thus following the addChoice method, I thought using a:
> >         addToSameRow()
> > followed by a
> >         addMessage
> > will be doing the job.
> > Very unfortunately, in this case the added message correctly shows up on
> > the same line than the choice but really really far away from the given
> > Choice Component.
> > As an alternative, I tryed then to use the following code:
> >         Component[]                     dlgItems        =
> > gd.getComponents();
> >         Component                       comp            = dlgItems[6];
> >         GridBagLayout                   grid            = (GridBagLayout)
> > gd.getLayout();
> >         GridBagConstraints              cst             =
> > grid.getConstraints(comp);
> >         cst.gridx                                       = cst.gridx - 20;
> >         cst.gridy                                       = cst.gridy - 1;
> >         grid.setConstraints(comp, cst);
> > But as I'm able to modify the cst.gridy value as wished, this isn't the
> > case for the cst.gridx one which seems to be kind of blocked.
> > Thus is there a way to define an unit value just following a Choice
> > Component?
> > I thank you very much in advance for your lights on this and wish you a
> > nice week-end.
> > My best regards,
> > Philippe
> >
> >
> > Philippe CARL
> > Laboratoire de Bioimagerie et Pathologies
> > UMR 7021 CNRS - Université de Strasbourg
> > Faculté de Pharmacie
> > 74 route du Rhin
> > <
> https://www.google.com/maps/search/74+route+du+Rhin?entry=gmail&source=g>
> > 67401 ILLKIRCH
> > Tel : +33(0)3 68 85 42 89
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> --
> -Kenneth Sloan
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
-Kenneth Sloan

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