Class NumericText

  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.opensubsystems.patterns.thickclient.application.swt.NumericText
All Implemented Interfaces:

public class NumericText
extends org.eclipse.swt.widgets.Composite

Text field allowing to type only numbers.

$Id:,v 1.2 2007/01/07 06:14:15 bastafidli Exp $
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
protected  boolean m_bDecimalPoint
          If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).
protected  char m_cDecimalPoint
          Decimal point character to use.
protected  java.lang.String m_strDecimalPoint
          Decimal point string to use.
protected  org.eclipse.swt.widgets.Text m_textField
          Text field used by this composite.
          Maximum number of digits allowed after the decimal point.
Fields inherited from class org.eclipse.swt.widgets.Composite
Fields inherited from class org.eclipse.swt.widgets.Widget
Constructor Summary
NumericText(org.eclipse.swt.widgets.Composite parent, int style, boolean bDecimalPoint)
          Create text field, which accepts only numbers.
Method Summary
 org.eclipse.swt.widgets.Layout createLayout()
          Create layout which will be used by this control.
 java.lang.String getDecimalPointText()
 org.eclipse.swt.widgets.Text getTextField()
          Get text field used by this composite.
 boolean setTextLimit(int iLimit)
          This function sets maximal number of characters typed.
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected char m_cDecimalPoint
Decimal point character to use.


protected java.lang.String m_strDecimalPoint
Decimal point string to use.


public static final int MAX_DECIMAL_DIGITS
Maximum number of digits allowed after the decimal point.

See Also:
Constant Field Values


protected org.eclipse.swt.widgets.Text m_textField
Text field used by this composite.


protected boolean m_bDecimalPoint
If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).

Constructor Detail


public NumericText(org.eclipse.swt.widgets.Composite parent,
                   int style,
                   boolean bDecimalPoint)
Create text field, which accepts only numbers.

parent - - parent which owns this text field
style - - style to use for this text field
bDecimalPoint - - if true, number can contain decimal point
Method Detail


public org.eclipse.swt.widgets.Text getTextField()
Get text field used by this composite.



public org.eclipse.swt.widgets.Layout createLayout()
Create layout which will be used by this control.

Layout - layout to use by this control.


public boolean setTextLimit(int iLimit)
This function sets maximal number of characters typed. If decimal point is allowed then this count has to include the decimal point. This method has to be called BEFORE any text is present in the field.

iLimit - - maximal number of characters
boolean - sucess flag


public java.lang.String getDecimalPointText()
String - string representing decimal point

Copyright © 2003 - 2006 OpenSubsystems s.r.o.