Posted by
Michael Schmid on
Apr 01, 2010; 2:55pm
URL: http://imagej.273.s1.nabble.com/Alter-dialog-fields-with-DialogListener-tp3688687p3688688.html
Hi Michael,
as fat as I understand it you want to change the text in a numeric
field after the dialog has been displayed?
You have to get the vector of nummeric input fields,
Vector nFields = gd.getNumericFields();
then extract the element at the correct position, cast it to
java.awt.TextField and do a setText(String), with a String
representing the number of your choice.
If it should be in response to a checkbox, do it in the
DialogItemStateChanged method of your plugin (it has to register as a
DialogListener for that) or as an ItemListener of the checkbox - you
get the reference to it from the vector obtained by gd.getCheckboxes().
Michael
________________________________________________________________
On 1 Apr 2010, at 15:20, Michael Doube wrote:
> Hi all
>
> I'm having a go at writing a dialog that responds to input by changing
> the the numbers and text it's displaying, which are then assigned to
> variables after OK is hit and gd.getNextNumber() etc. are called.
>
> Specifically I want the user to identify whether a particular state is
> true (their images are or are not Hounsfield unit calibrated) and
> (un)tick a checkbox, then enter thresholds based on HU calibrated
> or raw
> values.
>
> So, the values that have to change are the ones in the threshold
> boxes:
>
> gd.addNumericField("Bone Min:", this.min, 0, 6, pixUnits);
>
> this.min would change from the raw value to the calibrated value and
> pixUnits would change from "grey" to "HU".
>
> I had a go writing this with a DialogListener, using
> ij.plugin.SpecifyROI.java as an example, but have not been able to get
> my dialog box to update when the HU box is ticked.
>
> Any ideas or pointers to examples are welcome,
>
> Michael