GenericDialog components text to be or not to be enabled

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

GenericDialog components text to be or not to be enabled

CARL Philippe (LBP)
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)?
I thank you very much in advance for your lighting on this and wish you a nice end of 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
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

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

Re: GenericDialog components text to be or not to be enabled

Wayne Rasband-2
> 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
Reply | Threaded
Open this post in threaded view
|

Re: GenericDialog components text to be or not to be enabled

CARL Philippe (LBP)
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