Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Private Attributes
SharpTools.NumberField Class Reference

This class is used to only allow number input (int/float). More...

Inheritance diagram for SharpTools.NumberField:
Inheritance graph
[legend]
Collaboration diagram for SharpTools.NumberField:
Collaboration graph
[legend]

List of all members.

Classes

class  NumberFilterDocument

Public Member Functions

 NumberField (int columns)
 Construct a float-number only text field (including integer)
 NumberField (int columns, boolean positive)
 Construct a float-number only text field.
 NumberField (int columns, boolean positive, boolean integer)
 Construct a number only text field and can add more restriction as positive number only or integer only.
 NumberField (boolean positive, boolean integer)
 Construct a number only text field and can add more restriction as positive number only or integer only.
Float getNumber ()
 get the input float number
void setNumber (Float f)
 set the textfield to the specified float number
Integer getInteger ()
 When it's used as integer field, get the input integer number.
void setInteger (Integer i)
 When it's used as integer field, set the textfield to the specified integer number.

Private Attributes

boolean positiveOnly
boolean integer

Detailed Description

This class is used to only allow number input (int/float).

It extends JTextField and provides its own Document Filter.

For simplicity, now it uses InputVerifier - huaz

See also:
HistoDialog
NewFileDialog
AddressField
Author:
Hua Zhong
Version:
Revision:
1.7

Definition at line 27 of file NumberField.java.


Constructor & Destructor Documentation

SharpTools.NumberField.NumberField ( int  columns) [inline]

Construct a float-number only text field (including integer)

Parameters:
columnsthe length of the text field

Definition at line 40 of file NumberField.java.

                                    {
       super(columns);
       setDocument(new NumberFilterDocument());
       //     setInputVerifier(new NumberVerifier());
    }
SharpTools.NumberField.NumberField ( int  columns,
boolean  positive 
) [inline]

Construct a float-number only text field.

If positive is true only positive float number is allowed.

Parameters:
columnsthe length of the text field
positivethe value needs to be positive

Definition at line 53 of file NumberField.java.

                                                      {
       this(columns);
       this.positiveOnly = positive;
       setDocument(new NumberFilterDocument());
       //     setInputVerifier(new NumberVerifier());
    }
SharpTools.NumberField.NumberField ( int  columns,
boolean  positive,
boolean  integer 
) [inline]

Construct a number only text field and can add more restriction as positive number only or integer only.

Parameters:
columnsthe length of the text field
positivethe value needs to be positive
integerthe value needs to be an integer

Definition at line 68 of file NumberField.java.

                                                                       {
       this(columns);
       this.positiveOnly = positive;
       this.integer = integer;
       setDocument(new NumberFilterDocument());
       //     setInputVerifier(new NumberVerifier());
    }  
SharpTools.NumberField.NumberField ( boolean  positive,
boolean  integer 
) [inline]

Construct a number only text field and can add more restriction as positive number only or integer only.

Parameters:
positivethe value needs to be positive
integerthe value needs to be an integer

Definition at line 83 of file NumberField.java.

                                                          {
       super();
       this.positiveOnly = positive;
       this.integer = integer;
       setDocument(new NumberFilterDocument());
       //setInputVerifier(new NumberVerifier());
    }

Member Function Documentation

Integer SharpTools.NumberField.getInteger ( ) [inline]

When it's used as integer field, get the input integer number.

Returns:
an Integer object that converted from the user's input

Definition at line 123 of file NumberField.java.

                                {
       try {
           return new Integer(Integer.parseInt(getText()));
       }
       catch (Exception e) {
           return null;
       }
    }

Here is the caller graph for this function:

get the input float number

Returns:
a Float object that converted from the user's input

Definition at line 96 of file NumberField.java.

                             {
       try {
           return new Float(Float.parseFloat(getText()));
       }
       catch (Exception e) {
           return null;
       }
    }

Here is the caller graph for this function:

void SharpTools.NumberField.setInteger ( Integer  i) [inline]

When it's used as integer field, set the textfield to the specified integer number.

Parameters:
fa Float object

Definition at line 138 of file NumberField.java.

                                      {

       if (i == null)
           setText(null);
       else
           setText(i.toString());
    }
void SharpTools.NumberField.setNumber ( Float  f) [inline]

set the textfield to the specified float number

Parameters:
fa Float object

Definition at line 110 of file NumberField.java.

                                   {

       if (f == null)
           setText(null);
       else
           setText(f.toString());
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 33 of file NumberField.java.

Definition at line 32 of file NumberField.java.


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