acm.gui
Class DoubleField

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JTextField
                                |
                                +--acm.gui.DoubleField

public class DoubleField extends JTextField


   
Constructor Summary
DoubleField()
Creates a new field object for entering a double value.
DoubleField(double value)
Creates a new field object for entering a double value.
DoubleField(double low, double high)
Creates a new field object for entering a double value, which is constrained to be within the specified range.
DoubleField(double value, double low, double high)
Creates a new field object for entering a double value, which is constrained to be within the specified range.
 
Method Summary
boolean getExceptionOnError()
Returns the state of the error-handling flag.
String getFormat()
Returns the format currently in use for this field, or null if no format has been set.
double getValue()
Returns the value of this field as a double.
void setExceptionOnError(boolean flag)
Sets the error-handling mode of this interactor as specified by the flag parameter.
void setFormat(String format)
Sets the format used for the field.
void setValue(double d)
Sets the value of a field.
 

Constructor Detail

public DoubleField()

Creates a new field object for entering a double value. The contents of the field are initially blank.

 
Usage: DoubleField field = new DoubleField(); 
 

public DoubleField(double value)

Creates a new field object for entering a double value. The contents of the field initially contain the specified value.

 
Usage: DoubleField field = new DoubleField(value); 
Parameter: 
value  The value to store in the field
 

public DoubleField(double low, double high)

Creates a new field object for entering a double value, which is constrained to be within the specified range. The contents of the field are initially blank.

 
Usage: DoubleField field = new DoubleField(low, high); 
Parameters: 
low  The lowest value in the permitted range
high  The highest value in the permitted range
 

public DoubleField(double value, double low, double high)

Creates a new field object for entering a double value, which is constrained to be within the specified range. The contents of the field initially contain the specified value.

 
Usage: DoubleField field = new DoubleField(value, low, high); 
Parameters: 
value  The value to store in the field
low  The lowest value in the permitted range
high  The highest value in the permitted range
 
Method Detail

public boolean getExceptionOnError()

Returns the state of the error-handling flag.

 
Usage: boolean flag = console.getExceptionOnError(); 
Returns: The current setting of the error-handling mode (false to retry on errors; true to raise an exception)
 

public String getFormat()

Returns the format currently in use for this field, or null if no format has been set.

 
Usage: String format = field.getFormat(); 
Returns: The format for this field
 

public double getValue()

Returns the value of this field as a double. If this value is either not a legal numeric value or is outside the specified range, this method will either pop up a dialog allowing the user to reenter the value or throw an ErrorException depending on the state of the exceptionOnError flag.

 
Usage: double d = field.getValue(); 
Returns: The value stored in the field as a double
 

public void setExceptionOnError(boolean flag)

Sets the error-handling mode of this interactor as specified by the flag parameter. If flag is false (which is the default), calling getValue on this interactor displays a dialog that gives the user a chance to retry after erroneous input. If this value is set to true, illegal input raises an ErrorException instead.

 
Usage: field.setExceptionOnError(flag); 
Parameter: 
flag  false to retry on errors; true to raise an exception
 

public void setFormat(String format)

Sets the format used for the field. The structure of the format string is described in the comments for the DecimalFormat class. // Add links

 
Usage: field.setFormat(format); 
Parameter: 
format  The format to use for the field
 

public void setValue(double d)

Sets the value of a field.

 
Usage: field.setValue(d); 
Parameter: 
 The value to be stored in the field