com.nqadmin.swingSet
Class SSTextField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by com.nqadmin.swingSet.SSTextField
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable, javax.swing.SwingConstants

public class SSTextField
extends javax.swing.JTextField

SSTextField.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 SSTextField extends the JTextField. This class provides different masks
 like date mask, SSN mask etc.

Version:
$Revision: 1.26 $
Author:
$Author: prasanth $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTextField
javax.swing.JTextField.AccessibleJTextField
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String columnName
          SSRowSet column to which the component will be bound.
static int DDMMYYYY
          Use this mask if mm/dd/yyyy format is required.
static int DECIMAL
          Use this if the text field contains decimal number and want to limit number of decimal places.
protected  int mask
          Type of mask to be used for text field (default = none).
static int MMDDYYYY
          Use this mask if mm/dd/yyyy format is required.
protected  int numberOfDecimalPlaces
          Default number of decimals to show for float, double, etc.
static int SSN
          Use this if the text field contains SSN
protected  SSRowSet sSRowSet
          SSRowSet from which component will get/set values.
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SSTextField()
          Constructs a new, empty text field.
SSTextField(int _mask)
          Constructs a new, empty text field with the specified mask.
SSTextField(int _mask, int _numberOfDecimalPlaces)
          Constructs a new, empty text field with the specified mask & number of decimal places.
SSTextField(int _mask, int _numberOfDecimalPlaces, int _align)
          Constructs a new, empty text field with the specified mask, number of decimal places, & alignment.
SSTextField(SSRowSet _sSRowSet, java.lang.String _columnName)
          Creates a SSTextField instance and binds it to the specified SSRowSet column.
SSTextField(java.lang.String _text, int _mask)
          Constructs a new text field with the specified text & mask.
 
Method Summary
protected  void bind()
          Method for handling binding of component to a SSRowSet column.
 void bind(SSRowSet _sSRowSet, java.lang.String _columnName)
          Sets the SSRowSet and column name to which the component is to be bound.
protected  java.lang.String dateMask(java.lang.String _str, java.awt.event.KeyEvent _ke)
          Function to manage formatting date _strings with slashes as the user types to format date _string.
protected  java.lang.String decimalMask(java.lang.String _str, int numberOfDecimalPlaces)
          Function to modify the text for a decimal number as needed.
 java.lang.String getColumnName()
          Returns the SSRowSet column name to which the component is bound.
 int getMask()
          Returns the text field mask.
 int getNumberOfDecimalPlaces()
          Returns the number of decimal places required.
 SSRowSet getSSRowSet()
          Returns the SSRowSet to which the component is bound.
protected  void init()
          Initialization code.
protected  boolean mask(java.awt.event.KeyEvent _ke)
          Function to manage keystrokes for masks.
 void setColumnName(java.lang.String _columnName)
          Sets the SSRowSet column name to which the component is bound.
 void setMask(int _mask)
          Sets the text field mask.
 void setNumberOfDecimalPlaces(int _numberOfDecimalPlaces)
          Sets the number of decimal places required.
 void setSSRowSet(SSRowSet _sSRowSet)
          Sets the SSRowSet to which the component is bound.
protected  java.lang.String ssnMask(java.lang.String _str, java.awt.event.KeyEvent _ke)
          Function to format SSN
 
Methods inherited from class javax.swing.JTextField
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MMDDYYYY

public static final int MMDDYYYY
Use this mask if mm/dd/yyyy format is required.

See Also:
Constant Field Values

DDMMYYYY

public static final int DDMMYYYY
Use this mask if mm/dd/yyyy format is required.

See Also:
Constant Field Values

SSN

public static final int SSN
Use this if the text field contains SSN

See Also:
Constant Field Values

DECIMAL

public static final int DECIMAL
Use this if the text field contains decimal number and want to limit number of decimal places.

See Also:
Constant Field Values

sSRowSet

protected SSRowSet sSRowSet
SSRowSet from which component will get/set values.


columnName

protected java.lang.String columnName
SSRowSet column to which the component will be bound.


mask

protected int mask
Type of mask to be used for text field (default = none).


numberOfDecimalPlaces

protected int numberOfDecimalPlaces
Default number of decimals to show for float, double, etc.

Constructor Detail

SSTextField

public SSTextField(java.lang.String _text,
                   int _mask)
Constructs a new text field with the specified text & mask.

Parameters:
_text - the text to be displayed.
_mask - the mask required for this textfield.

SSTextField

public SSTextField(int _mask)
Constructs a new, empty text field with the specified mask.

Parameters:
_mask - the mask required for this textfield.

SSTextField

public SSTextField()
Constructs a new, empty text field.


SSTextField

public SSTextField(int _mask,
                   int _numberOfDecimalPlaces)
Constructs a new, empty text field with the specified mask & number of decimal places. Use this constructor only if you are using a decimal mask.

Parameters:
_mask - the mask required for this textfield.
_numberOfDecimalPlaces - number of decimal places required

SSTextField

public SSTextField(int _mask,
                   int _numberOfDecimalPlaces,
                   int _align)
Constructs a new, empty text field with the specified mask, number of decimal places, & alignment. Use this constructor only if you are using a decimal mask.
 (Horizontal alignment).
 Valid aligmnets are:
  JTextField.LEFT
  JTextField.CENTER
  JTextField.RIGHT
  JTextField.LEADING
  JTextField.TRAILING

 Use this constructor only if you are using a decimal mask.

Parameters:
_mask - the mask required for this text field.
_numberOfDecimalPlaces - number of decimal places required
_align - alignment required

SSTextField

public SSTextField(SSRowSet _sSRowSet,
                   java.lang.String _columnName)
Creates a SSTextField instance and binds it to the specified SSRowSet column.

Parameters:
_sSRowSet - datasource to be used.
_columnName - name of the column to which this label should be bound
Method Detail

setColumnName

public void setColumnName(java.lang.String _columnName)
Sets the SSRowSet column name to which the component is bound.

Parameters:
_columnName - column name in the SSRowSet to which the component is bound

getColumnName

public java.lang.String getColumnName()
Returns the SSRowSet column name to which the component is bound.

Returns:
column name to which the component is bound

setSSRowSet

public void setSSRowSet(SSRowSet _sSRowSet)
Sets the SSRowSet to which the component is bound.

Parameters:
_sSRowSet - SSRowSet to which the component is bound

getSSRowSet

public SSRowSet getSSRowSet()
Returns the SSRowSet to which the component is bound.

Returns:
SSRowSet to which the component is bound

setMask

public void setMask(int _mask)
Sets the text field mask.

Parameters:
_mask - the mask required for this text field.

getMask

public int getMask()
Returns the text field mask.

Returns:
editing mask for text field

setNumberOfDecimalPlaces

public void setNumberOfDecimalPlaces(int _numberOfDecimalPlaces)
Sets the number of decimal places required. This number is used only when mask is set to DECIMAL. Default value is 2.

Parameters:
_numberOfDecimalPlaces - desired # of decimal places

getNumberOfDecimalPlaces

public int getNumberOfDecimalPlaces()
Returns the number of decimal places required. This number is used only when mask is set to DECIMAL. Default value is 2.

Returns:
desired # of decimal places

bind

public void bind(SSRowSet _sSRowSet,
                 java.lang.String _columnName)
Sets the SSRowSet and column name to which the component is to be bound.

Parameters:
_sSRowSet - datasource to be used.
_columnName - Name of the column to which this check box should be bound

init

protected void init()
Initialization code.


bind

protected void bind()
Method for handling binding of component to a SSRowSet column.


mask

protected boolean mask(java.awt.event.KeyEvent _ke)
Function to manage keystrokes for masks.

Parameters:
_ke - the KeyEvent that occured
Returns:
returns true if function has detected a key it does not want to respond to like function keys etc else true.

dateMask

protected java.lang.String dateMask(java.lang.String _str,
                                    java.awt.event.KeyEvent _ke)
Function to manage formatting date _strings with slashes as the user types to format date _string.

Parameters:
_str - the present string in the text field.
_ke - the KeyEvent that occured
Returns:
returns the formated string.

ssnMask

protected java.lang.String ssnMask(java.lang.String _str,
                                   java.awt.event.KeyEvent _ke)
Function to format SSN

Parameters:
_str - the present string in the text field.
_ke - the KeyEvent that occured
Returns:
returns the formated string.

decimalMask

protected java.lang.String decimalMask(java.lang.String _str,
                                       int numberOfDecimalPlaces)
Function to modify the text for a decimal number as needed.

Parameters:
_str - the present string in the text field.
numberOfDecimalPlaces - number of decimal places allowed
Returns:
returns the formatted string.