Posted by
CARL Philippe (LBP) on
Jul 19, 2020; 1:44am
URL: http://imagej.273.s1.nabble.com/GenericDialog-components-text-to-be-or-not-to-be-enabled-tp5023548p5023736.html
Dear Wayne,
The GenericDialog getLabel() method you described below is working fine for the java.lang.String_label but not the java.lang.String_units of a numericFields created with the method:
addNumericField(java.lang.String label, double defaultValue, int digits, int columns, java.lang.String units)
My best regards,
Philippe
----- Mail original -----
De: "Wayne Rasband" <
[hidden email]>
À: "imagej" <
[hidden email]>
Envoyé: Lundi 22 Juin 2020 01:22:04
Objet: Re: GenericDialog components text to be or not to be enabled
> On Jun 21, 2020, at 10:05 AM, CARL Philippe (LBP) <
[hidden email]> wrote:
>
> Dear all,
> For a given application, I need to disable (i.e. by using ".setEnabled(false);") some GenericDialog components.
> And when I'm doing so, the checkboxes and the text associated to them become grey (as I expect it).
> But this isn't the case with the texts associated to the TextFields, Sliders and Choices (i.e. only the TextFields, Sliders and Choices contents become grey and inactive but not the text linked to them).
> Thus could there be done something so that the texts associated to all GenericDialog components become grey when disabled (whatever type they are)?
Use use the getLabel() method to get a reference to the label of the most recently added TextField, Slider, Choice, etc. Here is a JavaScript example:
gd = new GenericDialog("Test");
gd.addStringField("Text: ", "abc");
gd.getLabel().setEnabled(false);
gd.addChoice("Choice:",["a","b","c"],"a");
gd.getLabel().setEnabled(false);
gd.addSlider("Slider", 0, 100, 50);
gd.getLabel().setEnabled(false);
gd.showDialog();
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html