Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
GenericDialog Class Reference
Inheritance diagram for GenericDialog:

Public Member Functions

 GenericDialog (String title)
 
 GenericDialog (String title, ij.ImageJ parent)
 
 GenericDialog (String title, JApplet parent)
 
void addNumericField (String label, double defaultValue, int digits)
 
void addNumericField (String label, double defaultValue, int digits, int columns, String units)
 
void addStringField (String label, String defaultText)
 
void addStringField (String label, String defaultText, int columns)
 
void addCheckbox (String label, boolean defaultValue)
 
void addCheckboxGroup (int rows, int columns, String[] labels, boolean[] defaultValues)
 
void addChoice (String label, String[] items, String defaultItem)
 
void addMessage (String text)
 
void addTextAreas (String text1, String text2, int rows, int columns)
 
void addSlider (String label, double minValue, double maxValue, double defaultValue)
 
void addPanel (Panel panel)
 
void addPanel (Panel panel, int contraints, Insets insets)
 
boolean wasCanceled ()
 
double getNextNumber ()
 
boolean invalidNumber ()
 
String getErrorMessage ()
 
String getNextString ()
 
boolean getNextBoolean ()
 
String getNextChoice ()
 
int getNextChoiceIndex ()
 
String getNextText ()
 
void showDialog ()
 
Vector getNumericFields ()
 
Vector getStringFields ()
 
Vector getCheckboxes ()
 
Vector getChoices ()
 
Vector getSliders ()
 
TextArea getTextArea1 ()
 
TextArea getTextArea2 ()
 
void actionPerformed (ActionEvent e)
 
void textValueChanged (TextEvent e)
 
void itemStateChanged (ItemEvent e)
 
void focusGained (FocusEvent e)
 
void focusLost (FocusEvent e)
 
void keyPressed (KeyEvent e)
 
void keyReleased (KeyEvent e)
 
void keyTyped (KeyEvent e)
 
Insets getInsets ()
 
synchronized void adjustmentValueChanged (AdjustmentEvent e)
 
void paint (Graphics g)
 

Protected Member Functions

Double getValue (String theText)
 
void setup ()
 

Protected Attributes

Vector numberField
 
TextArea textArea1
 
Vector defaultValues
 
Component theLabel
 

Detailed Description

This class is a customizable modal dialog box. Here is an example GenericDialog with one string field and two numeric fields:

 public class Generic_Dialog_Example implements PlugIn {
   static String title="Example";
   static int width=512,height=512;
   public void run(String arg) {
     GenericDialog gd = new GenericDialog("New Image");
     gd.addStringField("Title: ", title);
     gd.addNumericField("Width: ", width, 0);
     gd.addNumericField("Height: ", height, 0);
     gd.showDialog();
     if (gd.wasCanceled()) return;
     title = gd.getNextString();
     width = (int)gd.getNextNumber();
     height = (int)gd.getNextNumber();
     IJ.run("New...", "name="+title+" type='8-bit Unsigned' width="+width+" height="+height);
  }
}

Definition at line 33 of file GenericDialog.java.

Constructor & Destructor Documentation

GenericDialog ( String  title)
inline

Creates a new GenericDialog with the specified title. Uses the current image image window as the parent frame or the ImageJ frame if no image windows are open. Dialog parameters are recorded by ImageJ's command recorder but this requires that the first word of each label be unique.

Definition at line 57 of file GenericDialog.java.

GenericDialog ( String  title,
JApplet  parent 
)
inline

Creates a new GenericDialog using the specified title and parent frame.

Definition at line 74 of file GenericDialog.java.

Member Function Documentation

void addCheckbox ( String  label,
boolean  defaultValue 
)
inline

Adds a checkbox.

Parameters
labelthe label
defaultValuethe initial state

Definition at line 209 of file GenericDialog.java.

void addCheckboxGroup ( int  rows,
int  columns,
String[]  labels,
boolean[]  defaultValues 
)
inline

Adds a group of checkboxs using a grid layout.

Parameters
rowsthe number of rows
columnsthe number of columns
labelsthe labels
defaultValuesthe initial states

Definition at line 235 of file GenericDialog.java.

void addChoice ( String  label,
String[]  items,
String  defaultItem 
)
inline

Adds a popup menu.

Parameters
labelthe label
itemsthe menu items
defaultItemthe menu item initially selected

Definition at line 272 of file GenericDialog.java.

void addMessage ( String  text)
inline

Adds a message consisting of one or more lines of text.

Definition at line 299 of file GenericDialog.java.

void addNumericField ( String  label,
double  defaultValue,
int  digits 
)
inline

Adds a numeric field. The first word of the label must be unique or command recording will not work.

Parameters
labelthe label
defaultValuevalue to be initially displayed
digitsnumber of digits to right of decimal point

Definition at line 92 of file GenericDialog.java.

void addNumericField ( String  label,
double  defaultValue,
int  digits,
int  columns,
String  units 
)
inline

Adds a numeric field. The first word of the label must be unique or command recording will not work.

Parameters
labelthe label
defaultValuevalue to be initially displayed
digitsnumber of digits to right of decimal point
columnswidth of field in characters
unitsa string displayed to the right of the field

Definition at line 104 of file GenericDialog.java.

void addPanel ( Panel  panel)
inline

Adds a Panel to the dialog.

Definition at line 420 of file GenericDialog.java.

void addPanel ( Panel  panel,
int  contraints,
Insets  insets 
)
inline

Adds a Panel to the dialog with custom contraint and insets. The defaults are GridBagConstraints.WEST (left justified) and "new Insets(5, 0, 0, 0)" (5 pixels of padding at the top).

Definition at line 427 of file GenericDialog.java.

void addStringField ( String  label,
String  defaultText 
)
inline

Adds an 8 column text field.

Parameters
labelthe label
defaultTextthe text initially displayed

Definition at line 169 of file GenericDialog.java.

void addStringField ( String  label,
String  defaultText,
int  columns 
)
inline

Adds a text field.

Parameters
labelthe label
defaultTexttext initially displayed
columnswidth of the text field

Definition at line 178 of file GenericDialog.java.

void addTextAreas ( String  text1,
String  text2,
int  rows,
int  columns 
)
inline

Adds one or two (side by side) text areas.

Parameters
text1initial contents of the first text area
text2initial contents of the second text area or null
rowsthe number of rows
rowsthe number of columns

Definition at line 320 of file GenericDialog.java.

Vector getCheckboxes ( )
inline

Returns the Vector containing the Checkboxes.

Definition at line 636 of file GenericDialog.java.

Vector getChoices ( )
inline

Returns the Vector containing the Choices.

Definition at line 641 of file GenericDialog.java.

String getErrorMessage ( )
inline

Returns an error message if getNextNumber was unable to convert a string into a number, otherwise, returns null.

Definition at line 512 of file GenericDialog.java.

boolean getNextBoolean ( )
inline

Returns the state of the next checkbox.

Definition at line 530 of file GenericDialog.java.

String getNextChoice ( )
inline

Returns the selected item in the next popup menu.

Definition at line 542 of file GenericDialog.java.

int getNextChoiceIndex ( )
inline

Returns the index of the selected item in the next popup menu.

Definition at line 554 of file GenericDialog.java.

double getNextNumber ( )
inline

Returns the contents of the next numeric field.

Definition at line 443 of file GenericDialog.java.

String getNextString ( )
inline

Returns the contents of the next text field.

Definition at line 517 of file GenericDialog.java.

String getNextText ( )
inline

Returns the contents of the next text area.

Definition at line 566 of file GenericDialog.java.

Vector getNumericFields ( )
inline

Returns the Vector containing the numeric TextFields.

Definition at line 626 of file GenericDialog.java.

Vector getSliders ( )
inline

Returns the sliders (Scrollbars).

Definition at line 646 of file GenericDialog.java.

Vector getStringFields ( )
inline

Returns the Vector containing the string TextFields.

Definition at line 631 of file GenericDialog.java.

TextArea getTextArea1 ( )
inline

Returns a reference to textArea1.

Definition at line 651 of file GenericDialog.java.

TextArea getTextArea2 ( )
inline

Returns a reference to textArea2.

Definition at line 656 of file GenericDialog.java.

boolean invalidNumber ( )
inline

Returns true if one or more of the numeric fields contained an invalid number. Must be called after one or more calls to getNextNumber().

Definition at line 504 of file GenericDialog.java.

void showDialog ( )
inline

Displays this dialog box.

Definition at line 586 of file GenericDialog.java.

boolean wasCanceled ( )
inline

Returns true if the user clicks on "Cancel".

Definition at line 438 of file GenericDialog.java.


The documentation for this class was generated from the following file: