![]() | ![]() |
![]() |
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 | | ![]()
Reply
| Post a New Message |
Join or Leave IMAGEJ, or Change Options
|
Search | ![]()
Chronologically |
Most Recent First |
Wrap Text (Proportional Font) |
Don't Wrap Text (Non-proportional Font) | ![]() |
Content-Type: text/plain; charset="us-ascii" Message-ID: <[log in to unmask]> Date: Mon, 27 May 2002 13:46:13 -0400 Reply-To: ImageJ Interest Group <[log in to unmask]> Sender: ImageJ Interest Group <[log in to unmask]> From: Wayne Rasband <[log in to unmask]> Subject: Re: Generic dialog... In-Reply-To: <8C3ACF2AFE15D411AFFD00805FA6303B252997@PFINT1>> 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); } }
![]() |
![]() Center for Information Technology National Institutes of Health Bethesda, Maryland 20892 301 594 6248 (v) 301 496 8294 (TDD) Comments and Assistance Accessibility ![]() |