NIH LISTSERV
NIH LISTSERV
IMAGEJ archives -- May 2002 (#177)

Go to: Previous Message | Next Message
Previous in Topic | Next in Topic
Previous by Same Author | Next by Same Author
Previous Page (May 2002) | Back to Main IMAGEJ Page


Options: Reply | Post a New Message | Join or Leave IMAGEJ, or Change Options | Search
View: Chronologically | Most Recent First | Wrap Text (Proportional Font) | Don't Wrap Text (Non-proportional Font)
*

Content-Type: text/plain
Message-ID:  <8C3ACF2AFE15D411AFFD00805FA6303B252999@PFINT1>
Date:         Tue, 28 May 2002 13:03:03 +0200
Reply-To:     ImageJ Interest Group <[log in to unmask]>
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         Gary Chinga <[log in to unmask]>
Subject:      Re: Generic dialog...

Thanks Wayne (and all the other replies), I have added your code to the plugin and it works greit! Regards, Gary. > -----Original Message----- > From: Wayne Rasband [SMTP:[log in to unmask]] > Sent: 27. mai 2002 19:46 > To: [log in to unmask] > Subject: Re: Generic dialog... > > > I am wondering if it is possible to change values in a dialog box > >automatically if one of the fields is changed. In the example below I > want > >the min Sample size (4) to change according to the entered pixel size. I > >also want to avoid having two different dialogs but both fields in the > same. > > > > GenericDialog gd = new GenericDialog("Roughness > >statistics..."); > > gd.addNumericField("Pixel size: ", 1, 0); > > gd.addNumericField("Sampling size: ", 4, 0); > > > > > > Thanks for any help, > > You can do this by subclassing GenericDialog. I have included an example > plugin that sets the sample size to four times the pixel size whenever the > pixel size is changed. The ScaleDialog (Analyze->Set Scale) and > FolderOpener (File->Import->Image Sequence) internal plugins also subclass > Generic Dialog. > > -wayne > > /*********** Generic_Dialog_Test.java *************/ > import ij.*; > import ij.process.*; > import ij.gui.*; > import java.awt.*; > import ij.plugin.*; > import java.awt.event.*; > > public class Generic_Dialog_Test implements PlugIn { > static int pixelSize = 1; > static int sampleSize = 4; > > public void run(String arg) { > GenericDialog gd = new RoughnessDialog("Roughness statistics..."); > gd.addNumericField("Pixel size: ", pixelSize, 0); > gd.addNumericField("Sampling size: ", sampleSize, 0); > gd.showDialog(); > if (gd.wasCanceled()) > return; > pixelSize = (int)gd.getNextNumber(); > pixelSize = (int)gd.getNextNumber(); > } > } > > class RoughnessDialog extends GenericDialog { > int oldPixelSize = 0; > > RoughnessDialog(String title) { > super(title); > } > > public void textValueChanged(TextEvent e) { > TextField tf1 = ((TextField)numberField.elementAt(0)); > Double d = getValue(tf1.getText()); > if (d==null) > return; > int pixelSize = (int)d.doubleValue(); > if (pixelSize==oldPixelSize) > return; > oldPixelSize = pixelSize; > int sampleSize = 4*pixelSize; > TextField tf2 = ((TextField)numberField.elementAt(1)); > tf2.setText(""+sampleSize); > } > > }




Back to: Top of message | Previous page | Main IMAGEJ page

NIH LISTSERV Home Page

CIT
Center for Information Technology
National Institutes of Health
Bethesda, Maryland 20892
301 594 6248 (v) 301 496 8294 (TDD)
Comments and Assistance
Accessibility wheelchair icon