javabook
Class MultiInputBox

java.lang.Object
  extended byjavabook.JavaBookDialog
      extended byjavabook.MultiInputBox

public class MultiInputBox
extends JavaBookDialog

This dialog is for accepting multiple input values. Input values are returned as an array of String objects. You have to convert the String values to appropriate data type in your code.

This class is provided as freeware. You are free to use as provided or modify to your heart's content. But you use it at your own risk. No implied or explicit warranty is given.


Field Summary
static java.lang.String[] NO_ITEM
          Constant to represent no selection for the getSelectedItem method.
 
Fields inherited from class javabook.JavaBookDialog
ERROR_ICON, INFO_ICON, NO_ICON, QUESTION_ICON, WARNING_ICON
 
Constructor Summary
MultiInputBox(java.awt.Frame owner, int size)
          Constructs a MultiInputBox with the owner frame and size input lines.
MultiInputBox(java.awt.Frame owner, java.lang.String[] labels)
          Constructs a MultiInputBox with the owner frame and labels for input lines.
 
Method Summary
 java.lang.String[] getInputs()
          Returns the input values entered by the user.
 boolean isCanceled()
          Returns true if the state of this dialog is CANCEL.
 void setLabels(java.lang.String[] label)
          Assigns the input line labels to the passed array
 void setResetOption(boolean option)
          Sets the reset flag.
 void setValue(int index, java.lang.String value)
          Sets the value to the input line at the index position.
 
Methods inherited from class javabook.JavaBookDialog
setIcon, setLocation, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ITEM

public static final java.lang.String[] NO_ITEM
Constant to represent no selection for the getSelectedItem method.

Constructor Detail

MultiInputBox

public MultiInputBox(java.awt.Frame owner,
                     int size)
Constructs a MultiInputBox with the owner frame and size input lines.

Parameters:
owner - the owning Frame object
size - the number of input lines

MultiInputBox

public MultiInputBox(java.awt.Frame owner,
                     java.lang.String[] labels)
Constructs a MultiInputBox with the owner frame and labels for input lines.

Parameters:
owner - the owning Frame object
labels - the array of String for input line labels
Method Detail

getInputs

public java.lang.String[] getInputs()
Returns the input values entered by the user. If the user clicks the close box or the Cancel button, NO_ITEM is returned. In this case, a subsequent call to isCanceled will return true. If the user clicks the Ok button, an array of Sring is returned. For those input lines that contain no input value, the corresponding element in the array is an empty string.

Returns:
an array of String values entered by the user

isCanceled

public boolean isCanceled()
Returns true if the state of this dialog is CANCEL.

Returns:
the state of this dialog; true if CANCEL; false otherwise

setLabels

public void setLabels(java.lang.String[] label)
Assigns the input line labels to the passed array

Parameters:
label - an array of String for input line labels

setResetOption

public void setResetOption(boolean option)
Sets the reset flag. Pass true to clear the input fields after the getInputs method is called. It is useful to set the flag to false, so the input fields are not reset when you enter a number of similar data. Default is true so the input fields are cleared after each appearance of this dialog.

Parameters:
option - pass 'true' to reset the input fields

setValue

public void setValue(int index,
                     java.lang.String value)
Sets the value to the input line at the index position. This method is useful to set default input values so the user gets an hint on the type of values expected in the input lines. This method does nothing when the index value is invalid.

Parameters:
index - the position of the input line to set the value
value - the value to assign to the input line