com.retek.commons.gui.widget
Class RTextField

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.text.JTextComponent
                  extended byjavax.swing.JTextField
                      extended bycom.retek.commons.gui.widget.RTextField
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.SwingConstants, WidgetInterface
Direct Known Subclasses:
RCurrencyField

public class RTextField
extends javax.swing.JTextField
implements java.awt.event.KeyListener, WidgetInterface

This class sub-classes the standard JTextField class in the Swing package to provide custom functionality for the Rcom client application.

This widgets has the ability to limit the number of character allowed in the field. RTextFields will remain disabled until and entry length is specified.

Retek Inc. Copyright (c) 2002

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTextField
javax.swing.JTextField.AccessibleJTextField
 
Nested classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Mask formatMask
           
 
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
RTextField()
          Returns a new RTextField object.
 
Method Summary
 void clear()
          Clears the text field of input.
 java.lang.String getClusterName()
          Retrieves the cluster name of the widget.
 int getLength()
          Returns the allowable text length.
 java.lang.String getText()
          Retrieves the text string from the text field and returns the unformatted and trimmed version of the text.
 java.lang.String getUnformattedText()
          Retrieves the text string from the text field.
 boolean isEmpty()
          Retrieves whether or not the text field is empty.
 boolean isErrorState()
          Retrieves whether or not the text field is in an error state.
 boolean isFormatInvalid()
          Retrieves whether or not the information in the text field fails the format validation.
 boolean isTextModified()
          Retrieves whether or not the text field has been modified since the last setText() occurred or focus was gained.
 void keyPressed(java.awt.event.KeyEvent event)
          Implements the key listener interface "key pressed" method.
 void keyReleased(java.awt.event.KeyEvent event)
          Implements the key listener interface "key released" method.
 void keyTyped(java.awt.event.KeyEvent event)
          Implements the key listener interface "key typed" method.
 void paste()
          Overrides paste() to make sure they do not paste more text than the field is allowed.
 void refresh()
          Refreshes the text field (this will trigger the formatting and line length logic) and reset the value of the field.
 void removeMask()
          Removes the mask assigned to this text field.
 void resetModifiedState()
          Sets the modified state of the widget.
 void setBackground(java.awt.Color color)
           
 void setClusterName(java.lang.String clusterName)
          Sets the cluster name of the widget.
 void setDefaultSize(int width, int height, int length)
          Sets the minimum and preferred width and height of the text field as well as the number of characters allowed in the field.
 void setEnabled(boolean enabled)
          Overrides the superclass method in order to not only set the enabled state, but also update the color state of the text field.
 void setErrorState(boolean errorState)
          Sets the colors of the text field to an error state.
 void setFocusedState()
          Sets the text field to focused state, updating colors.
 void setForeground(java.awt.Color color)
           
 void setFormatInvalid(boolean formatInvalid)
          Sets whether or not the text field has invalidly formatted data in the field.
 void setLength(int textLength)
          Sets the allowable text length.
 void setMask(Mask formatMask)
          Assigns a format mask to the text field.
 void setMinimumSize(int width, int height)
          Sets the minimum and preferred width and height of the text field.
 void setMinimumWidth(int width)
          Sets the minimum and preferred width of the text field.
 void setQuickEntries(java.util.Map map)
          Sets the quick entry keystroke to replacement string mapping for the text field.
 void setText(java.lang.String text)
          Assigns the text in the field.
 void setText(java.lang.String[] textArray)
          Assigns the text in the text field, formatted from a string array through a mask.
 void setUseInactiveColor(boolean useColor)
          Sets whether or not to use the inactive color state of the text field.
 void updateColorState()
          Updates the color state.
 
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, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 
Methods inherited from interface com.retek.commons.gui.core.WidgetInterface
getName, setName
 

Field Detail

formatMask

protected Mask formatMask
Constructor Detail

RTextField

public RTextField()
Returns a new RTextField object.

Method Detail

setMinimumWidth

public void setMinimumWidth(int width)
Sets the minimum and preferred width of the text field. This method uses the default line height value to determine the minimum and preferred height.

Parameters:
width - The width in pixels.

setMinimumSize

public void setMinimumSize(int width,
                           int height)
Sets the minimum and preferred width and height of the text field.

Parameters:
width - The width in pixels.
height - The height in pixels.

setDefaultSize

public void setDefaultSize(int width,
                           int height,
                           int length)
Sets the minimum and preferred width and height of the text field as well as the number of characters allowed in the field.

Parameters:
width - The width in pixels.
height - The height in pixels.
length - The length in characters that the text field should allow.

setLength

public void setLength(int textLength)
Sets the allowable text length. The text field will only allow users to enter up to this length in characters before it stops processing keystrokes.


getLength

public int getLength()
Returns the allowable text length.

Returns:
The length in characters that the text field should allow.

setUseInactiveColor

public void setUseInactiveColor(boolean useColor)
Sets whether or not to use the inactive color state of the text field. If true, a special color will be assigned to the text field. If false, it will not.

Parameters:
useColor - True if inactive colors should be used, false if not.

setEnabled

public void setEnabled(boolean enabled)
Overrides the superclass method in order to not only set the enabled state, but also update the color state of the text field.

Parameters:
enabled - True if the field should be enabled, false if it should be disabled.

setMask

public void setMask(Mask formatMask)
Assigns a format mask to the text field. The specific mask is cast to the interface for generic operability.

Parameters:
formatMask - A format mask to assign to this text field.

removeMask

public void removeMask()
Removes the mask assigned to this text field.


paste

public void paste()
Overrides paste() to make sure they do not paste more text than the field is allowed.


refresh

public void refresh()
Refreshes the text field (this will trigger the formatting and line length logic) and reset the value of the field.


setText

public void setText(java.lang.String text)
Assigns the text in the field. The text will be formatted if a mask exists. Text longer than the allowed length is, interestingly, not allowed.

Parameters:
text - The text to place in the text field.

setText

public void setText(java.lang.String[] textArray)
Assigns the text in the text field, formatted from a string array through a mask.

Parameters:
textArray - An array of strings to format through a mask.

getText

public java.lang.String getText()
Retrieves the text string from the text field and returns the unformatted and trimmed version of the text.

Returns:
The unformatted and trimmed text.

getUnformattedText

public java.lang.String getUnformattedText()
Retrieves the text string from the text field. Overrides superclass to handle unformatting.

Returns:
The unformatted text.

isTextModified

public boolean isTextModified()
Retrieves whether or not the text field has been modified since the last setText() occurred or focus was gained.

Returns:
True if the text field is modified, false if not.

resetModifiedState

public void resetModifiedState()
Sets the modified state of the widget.


isEmpty

public boolean isEmpty()
Retrieves whether or not the text field is empty.

Returns:
True if the text field is empty, false if not.

clear

public void clear()
Clears the text field of input.


setFormatInvalid

public void setFormatInvalid(boolean formatInvalid)
Sets whether or not the text field has invalidly formatted data in the field.

Parameters:
formatInvalid - True if the text field currently has invalid data, false if not.

isFormatInvalid

public boolean isFormatInvalid()
Retrieves whether or not the information in the text field fails the format validation.

Returns:
True if the format is invalid, false otherwise.

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
Implements the key listener interface "key released" method. If quick entries has been activated for the text area, then the current built word must be reinitialized if a key was released and the SHIFT and ALT is not pressed.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that occurred.

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Implements the key listener interface "key pressed" method. The method tracks whether or not the key pressed was the backspace or delete key. In addition, if the ENTER key is pressed, it transfers the focus to the next focusable field.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that occurred.

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
Implements the key listener interface "key typed" method. It captures the key typed action, checks to see if the allowable length is reached and if the key is not a backspace/delete/left arrow key, then the key is ignored.

If the text in the field is selected, a new keystroke would replace the selected text and by default that means we cannot allow the event to continue.

If quick entry has been activated, the system must look for SHIFT/ALT and then find if the sequence of characters in the built up word exists in the quickmap. If it does the information should replace the text in the text area.

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that occurred.

setQuickEntries

public void setQuickEntries(java.util.Map map)
Sets the quick entry keystroke to replacement string mapping for the text field.


setClusterName

public void setClusterName(java.lang.String clusterName)
Sets the cluster name of the widget. A cluster name associates a group of widgets.

Specified by:
setClusterName in interface WidgetInterface
Parameters:
clusterName - The cluster name to assign to the widget.

getClusterName

public java.lang.String getClusterName()
Retrieves the cluster name of the widget.

Specified by:
getClusterName in interface WidgetInterface

setBackground

public void setBackground(java.awt.Color color)
See Also:
in JTextField.

setForeground

public void setForeground(java.awt.Color color)
See Also:
in JTextField.

setErrorState

public void setErrorState(boolean errorState)
Sets the colors of the text field to an error state. This will also grab the focus and select all the text in the feild if the text field is locked.

Specified by:
setErrorState in interface WidgetInterface

isErrorState

public boolean isErrorState()
Retrieves whether or not the text field is in an error state.

Specified by:
isErrorState in interface WidgetInterface
Returns:
True if the text field is in an error state, false if not

setFocusedState

public void setFocusedState()
Sets the text field to focused state, updating colors.

Specified by:
setFocusedState in interface WidgetInterface

updateColorState

public void updateColorState()
Updates the color state. This method ensures the color displayed by the widget is correct based on the state of the widget. The controlling color flag is to keep the set() methods from changing the default background color.



Copyright © 2005 Retek Inc. All Rights Reserved. - Generated at Fri, 01/21/2005 14:25