Re: GenericDialog Choice with units method
Posted by
Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/GenericDialog-Choice-with-units-method-tp5023727p5023731.html
> On Jul 17, 2020, at 11:44 AM, CARL Philippe (LBP) <
[hidden email]> wrote:
> Thus is there a way to define an unit value just following a Choice Component?
You can add the unit to the label, for example:
gd.addChoice("Width ("+unit+")", items, null);
I am reluctant to make changes to GenericDialog since it appears to slow down Fiji updates:
https://github.com/imagej/ij1-patcher/pull/47Fiji currently includes ImageJ 1.52p, released more than a year ago and seven versions out of date.
-wayne
> 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
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html