Login  Register

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

Posted by Wayne Rasband-2 on Jun 21, 2020; 11:22pm
URL: http://imagej.273.s1.nabble.com/GenericDialog-components-text-to-be-or-not-to-be-enabled-tp5023548p5023549.html

> 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