EchoPoint
1.0

echopoint
Class NumberFormatField

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.text.TextComponent
          extended bynextapp.echo.TextField
              extended byechopoint.TextField
                  extended byechopoint.NumberFormatField
All Implemented Interfaces:
Borderable, MouseCursorable, ReflectionSetter, java.io.Serializable, ToolTipPopUpSupport, nextapp.echo.ToolTipSupport, Validateable

public class NumberFormatField
extends TextField
implements ReflectionSetter

The NumberFormatField class is a Component that can be used as the baisis for allowing a user to enter in a numbers.

The NumberFormatField has a NumberFormat that is used to parse and sets its current value (remember it is derived from TextField).

Remember that at any one time the text value can be an invalid number. You must check the number in you code before accepting it as valid.

Author:
Brad Baker
See Also:
Serialized Form

Nested Class Summary
static class NumberFormatField.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static java.lang.String INVALID_COLOR_CHANGED_PROPERTY
           
static java.lang.String LOCALE_CHANGED_PROPERTY
          Locale Property
static java.lang.String NUMBER_FORMAT_CHANGED_PROPERTY
          NumberFormat Property
static java.lang.String STYLE_INVALID_COLOR
          Invalid Color Property
 
Fields inherited from class nextapp.echo.TextField
ACTION_COMMAND_CHANGED_PROPERTY, COLUMN_UNITS_CHANGED_PROPERTY, COLUMNS_CHANGED_PROPERTY, MAXIMUM_LENGTH_CHANGED_PROPERTY, STYLE_MAXIMUM_LENGTH
 
Fields inherited from class nextapp.echo.text.TextComponent
BORDER_COLOR_CHANGED_PROPERTY, BORDER_DEFAULT, BORDER_INSET, BORDER_NONE, BORDER_SIZE_CHANGED_PROPERTY, BORDER_SOLID, BORDER_STYLE_CHANGED_PROPERTY, CHARACTER_UNITS, DOCUMENT_CHANGED_PROPERTY, EDITABLE_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, PERCENT_UNITS, PIXEL_UNITS, STYLE_BORDER_COLOR, STYLE_BORDER_SIZE, STYLE_BORDER_STYLE, STYLE_COLUMNS, STYLE_HORIZONTAL_ALIGNMENT, STYLE_LINE_WRAP, STYLE_ROWS, TEXT_CHANGED_PROPERTY
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.Borderable
BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, borderStyleSymbolics, STYLE_BORDER_COLOR, STYLE_BORDER_SIZE, STYLE_BORDER_STYLE, STYLE_BOTTOM_BORDER_COLOR, STYLE_BOTTOM_BORDER_SIZE, STYLE_BOTTOM_BORDER_STYLE, STYLE_LEFT_BORDER_COLOR, STYLE_LEFT_BORDER_SIZE, STYLE_LEFT_BORDER_STYLE, STYLE_RIGHT_BORDER_COLOR, STYLE_RIGHT_BORDER_SIZE, STYLE_RIGHT_BORDER_STYLE, STYLE_TOP_BORDER_COLOR, STYLE_TOP_BORDER_SIZE, STYLE_TOP_BORDER_STYLE
 
Fields inherited from interface echopoint.positionable.MouseCursorable
borderStyleSymbolics, CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, STYLE_MOUSE_CURSOR, STYLE_MOUSE_CURSOR_URI
 
Fields inherited from interface nextapp.echo.ToolTipSupport
TOOL_TIP_TEXT_CHANGED_PROPERTY
 
Constructor Summary
NumberFormatField()
          Creates a NumberFormatField
NumberFormatField(int columns)
          Creates a NumberFormatField that is columns wide.
NumberFormatField(java.lang.Number number)
          Creates a NumberFormatField with number as the initial Date value.
NumberFormatField(java.lang.Number number, int columns)
          Creates a NumberFormatField with number as the initial value and a given column size.
NumberFormatField(java.lang.String text)
          Creates a NumberFormatField with text as the initial value.
NumberFormatField(java.lang.String text, int columns)
          Creates a NumberFormatField with text as the initial value and that is columns wide.
 
Method Summary
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
 nextapp.echo.Color getInvalidColor()
          Returns the color used by the NumberFormatField when an invalid Number value is currently entered.
 java.util.Locale getLocale()
          Returns the Locale used by the NumberFormatField for formatting Numbers
 java.lang.Number getNumber()
          This method will return a Number object created by parsing the current text in the NumberFormatField with the current NumberFormat.
 java.text.NumberFormat getNumberFormat()
          Returns the NumberFormat in use.
 boolean isValid()
          This method returns TRUE if the text of the NumberFormatField can be parsed into a valid Number with the current NumberFormat.
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setInvalidColor(nextapp.echo.Color newInvalidColor)
          Sets the color used by the NumberFormatField when an invalid Number value is currently entered.
 void setLocale(java.util.Locale newLocale)
          Sets the Locale used by the NumberFormatField for formatting Numbers
 void setNumber(java.lang.Number newValue)
          This will set the text of the NumberFormatField according to the current NumberFormat.
 void setNumberFormat(java.text.NumberFormat newNumberFormat)
          Sets the NumberFormat to be used by the NumberFormatField for displaying and parsing entered data.
 
Methods inherited from class echopoint.TextField
getBorderColor, getBorderSize, getBorderStyle, getBottomBorderColor, getBottomBorderSize, getBottomBorderStyle, getLeftBorderColor, getLeftBorderSize, getLeftBorderStyle, getMouseCursor, getMouseCursorURI, getRightBorderColor, getRightBorderSize, getRightBorderStyle, getRuleSet, getToolTipPopUp, getToolTipText, getTopBorderColor, getTopBorderSize, getTopBorderStyle, setBorderColor, setBorderSize, setBorderStyle, setBottomBorderColor, setBottomBorderSize, setBottomBorderStyle, setLeftBorderColor, setLeftBorderSize, setLeftBorderStyle, setMouseCursor, setMouseCursorURI, setRightBorderColor, setRightBorderSize, setRightBorderStyle, setRuleSet, setToolTipText, setTopBorderColor, setTopBorderSize, setTopBorderStyle, validate
 
Methods inherited from class nextapp.echo.TextField
addActionListener, fireActionEvent, getActionCommand, getColumns, getColumnUnits, getMaximumLength, hasActionListeners, removeActionListener, setActionCommand, setColumns, setColumnUnits, setMaximumLength
 
Methods inherited from class nextapp.echo.text.TextComponent
getDocument, getHorizontalAlignment, getText, isEditable, setDocument, setEditable, setHorizontalAlignment, setText
 
Methods inherited from class nextapp.echo.Component
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setEnabled, setFont, setForeground, setIdentifier, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface echopoint.validation.Validateable
getIdentifier, getText
 

Field Detail

INVALID_COLOR_CHANGED_PROPERTY

public static final java.lang.String INVALID_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

LOCALE_CHANGED_PROPERTY

public static final java.lang.String LOCALE_CHANGED_PROPERTY
Locale Property

See Also:
Constant Field Values

NUMBER_FORMAT_CHANGED_PROPERTY

public static final java.lang.String NUMBER_FORMAT_CHANGED_PROPERTY
NumberFormat Property

See Also:
Constant Field Values

STYLE_INVALID_COLOR

public static final java.lang.String STYLE_INVALID_COLOR
Invalid Color Property

See Also:
Constant Field Values
Constructor Detail

NumberFormatField

public NumberFormatField()
Creates a NumberFormatField


NumberFormatField

public NumberFormatField(int columns)
Creates a NumberFormatField that is columns wide.


NumberFormatField

public NumberFormatField(java.lang.Number number)
Creates a NumberFormatField with number as the initial Date value.


NumberFormatField

public NumberFormatField(java.lang.Number number,
                         int columns)
Creates a NumberFormatField with number as the initial value and a given column size.


NumberFormatField

public NumberFormatField(java.lang.String text)
Creates a NumberFormatField with text as the initial value.


NumberFormatField

public NumberFormatField(java.lang.String text,
                         int columns)
Creates a NumberFormatField with text as the initial value and that is columns wide.

Method Detail

applyStyle

public void applyStyle(nextapp.echo.Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface Borderable
Overrides:
applyStyle in class TextField
See Also:
Borderable.applyStyle(nextapp.echo.Style)

getInvalidColor

public nextapp.echo.Color getInvalidColor()
Returns the color used by the NumberFormatField when an invalid Number value is currently entered.

Returns:
nextapp.echo.Color

getLocale

public java.util.Locale getLocale()
Returns the Locale used by the NumberFormatField for formatting Numbers

Specified by:
getLocale in interface Validateable
Returns:
java.util.Locale

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Returns the NumberFormat in use.

Returns:
java.text.NumberFormat

getNumber

public java.lang.Number getNumber()
This method will return a Number object created by parsing the current text in the NumberFormatField with the current NumberFormat. If this parse is successful then a Number object will be returned, otherwise null will be returned.


setNumber

public void setNumber(java.lang.Number newValue)
This will set the text of the NumberFormatField according to the current NumberFormat.

Parameters:
newValue -

isValid

public boolean isValid()
This method returns TRUE if the text of the NumberFormatField can be parsed into a valid Number with the current NumberFormat.


setInvalidColor

public void setInvalidColor(nextapp.echo.Color newInvalidColor)
Sets the color used by the NumberFormatField when an invalid Number value is currently entered.

Parameters:
newInvalidColor - nextapp.echo.Color

setLocale

public void setLocale(java.util.Locale newLocale)
Sets the Locale used by the NumberFormatField for formatting Numbers

Parameters:
newLocale - java.util.Locale

setNumberFormat

public void setNumberFormat(java.text.NumberFormat newNumberFormat)
Sets the NumberFormat to be used by the NumberFormatField for displaying and parsing entered data.

Parameters:
newNumberFormat - java.text.NumberFormat

set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Specified by:
set in interface ReflectionSetter
Overrides:
set in class TextField
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0