Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.awt.field
Class FlexTextField  view FlexTextField download FlexTextField.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.TextComponent
          extended byjava.awt.TextField
              extended bycom.flexstor.common.awt.field.FlexTextField
All Implemented Interfaces:
javax.accessibility.Accessible, ComponentI, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.awt.event.TextListener

public class FlexTextField
extends java.awt.TextField
implements ComponentI, java.awt.event.TextListener

FlexTextField provides basic data type validation and custom enabling/disabling.


Nested Class Summary
 
Nested classes inherited from class java.awt.TextField
java.awt.TextField.AccessibleAWTTextField
 
Nested classes inherited from class java.awt.TextComponent
java.awt.TextComponent.AccessibleAWTTextComponent
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  boolean bNotifyListeners
           
private  boolean bPartialDisable
          The field always "appears" disabled when true.
private  boolean bRequired
          A value is required in this field if true.
private  boolean bShowError
          Error dialogs are shown when true.
private  com.flexstor.common.parsers.ValidatorI custValidator
          Custom (secondary) data validation object.
private  boolean disablePopOnFocusEvent
           
private  boolean isDialogShown
           
private  java.util.Vector keyListeners
          Key Listener -- used for reserved keys only.
private  int nCase
          The case from com.flexstor.common.constants.FieldConstantsI.
private  int nCurrentError
           
private  int nDispLength
          The display length in characters.
private static int[] RESERVED_KEYS
          Keys that are reserved for other uses, and will not be processed by this field.
(package private)  java.lang.String text
           
private  java.util.Vector textListeners
          Text Listeners -- used for filtering of text events.
private  com.flexstor.common.parsers.ValidatorI validator
          Data validation object.
 
Fields inherited from class java.awt.TextField
 
Fields inherited from class java.awt.TextComponent
textListener
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.flexstor.common.awt.field.ComponentI
COMBO_FIELD_HEIGHT, COMPONENT_HEIGHT, MAX_FIELD_LENGTH, TEXT_AREA_HEIGHT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FlexTextField()
          Creates a new text field with error messages turned on.
FlexTextField(int nColumns)
          Creates a new text field with error messages turned off.
 
Method Summary
 void addKeyListener(java.awt.event.KeyListener l)
          Adds the specified listener to this component.
 void addTextListener(com.flexstor.common.awt.event.FlexTextListener l)
           
 void cleanup()
           
 void clear(boolean bNotify)
          Sets field to a blank string.
 void configure(int nLength)
           
 void configure(int nType, int nLength, int nCase, boolean bEditable, boolean bRequired, java.lang.String sLabel)
          Configures the validator field.
 void configure(int nType, int nLength, int nCase, boolean bEditable, boolean bRequired, java.lang.String sLabel, boolean disablePopOnFocusEvent)
          Configures the validator field.
 void formatCase()
          Formats a text field to its defined case.
 boolean getEnabled()
           
 long getId()
           
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this text field.
private  java.awt.Frame getParentFrame()
           
 java.awt.Dimension getPreferredSize()
          Returns the preferred size for this text field.
 boolean isBlank()
          Returns the true if the field empty.
 boolean isRequired()
           
 boolean keyDown(java.awt.Event e, int i)
          Overiding keyDown() in order to suppress some of the JClass hotkeys.
protected  void processFocusEvent(java.awt.event.FocusEvent e)
          Processes focus.
 void processKeyEvent(java.awt.event.KeyEvent e)
          Called when a key event is dispatched and component events are enabled.
 boolean quietVerify()
          Verifies the field attributes without displaying any errors.
 void removeKeyListener(java.awt.event.KeyListener l)
          Removes the specified listener from the component.
 void removeTextListener(com.flexstor.common.awt.event.FlexTextListener l)
           
 void requestFocus()
          Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window.
 void setBounds(int x, int y, int width, int height)
          Sets the bounding rectangle for this component to the specified values.
private  void setCurrentErrorNo(int nError)
           
 void setCustomValidator(com.flexstor.common.parsers.ValidatorI validator)
           
 void setDisplayLength(int nLength)
          Sets the "display" length (in characters) for this field.
 void setEnabled(boolean bState)
          Enables/disables input for this field, but you can still scroll through the field.
 void setId(long nId)
           
 void setPartialDisable(boolean bState)
          Instructs this field to always "look" disabled, even when enabled.
 void setPasswordMode()
           
 void setRequired(boolean bRequired)
           
 void setShowError(boolean bState)
           
 void setText(java.lang.String sText)
          Sets the text in this component to the specified string.
private  void setup(boolean bShowErr)
           
private  void showError(int nError)
           
private  void showMsgDialog()
           
 void textValueChangeBegin(java.awt.event.TextEvent e)
           
 void textValueChanged(java.awt.event.TextEvent arg0)
          This method is called when the text being monitored changes.
 boolean verify(boolean bCheckRequired)
          Verifies that the data in the field is valid.
 
Methods inherited from class java.awt.TextField
addActionListener, addNotify, echoCharIsSet, getAccessibleContext, getActionListeners, getColumns, getEchoChar, getListeners, getMinimumSize, getPreferredSize, minimumSize, minimumSize, paramString, preferredSize, preferredSize, processActionEvent, processEvent, removeActionListener, setColumns, setEchoChar, setEchoCharacter
 
Methods inherited from class java.awt.TextComponent
addTextListener, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processTextEvent, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.flexstor.common.awt.field.ComponentI
getText
 

Field Detail

nCase

private int nCase
The case from com.flexstor.common.constants.FieldConstantsI.


bShowError

private boolean bShowError
Error dialogs are shown when true.


nDispLength

private int nDispLength
The display length in characters.


bPartialDisable

private boolean bPartialDisable
The field always "appears" disabled when true.


bRequired

private boolean bRequired
A value is required in this field if true.


isDialogShown

private boolean isDialogShown

validator

private com.flexstor.common.parsers.ValidatorI validator
Data validation object.


custValidator

private com.flexstor.common.parsers.ValidatorI custValidator
Custom (secondary) data validation object.


textListeners

private java.util.Vector textListeners
Text Listeners -- used for filtering of text events.


keyListeners

private java.util.Vector keyListeners
Key Listener -- used for reserved keys only.


bNotifyListeners

private boolean bNotifyListeners

nCurrentError

private int nCurrentError

disablePopOnFocusEvent

private boolean disablePopOnFocusEvent

RESERVED_KEYS

private static final int[] RESERVED_KEYS
Keys that are reserved for other uses, and will not be processed by this field.


text

java.lang.String text
Constructor Detail

FlexTextField

public FlexTextField()
Creates a new text field with error messages turned on.


FlexTextField

public FlexTextField(int nColumns)
Creates a new text field with error messages turned off.

Method Detail

cleanup

public void cleanup()
Specified by:
cleanup in interface ComponentI

setup

private void setup(boolean bShowErr)

configure

public void configure(int nType,
                      int nLength,
                      int nCase,
                      boolean bEditable,
                      boolean bRequired,
                      java.lang.String sLabel)
Configures the validator field.


configure

public void configure(int nType,
                      int nLength,
                      int nCase,
                      boolean bEditable,
                      boolean bRequired,
                      java.lang.String sLabel,
                      boolean disablePopOnFocusEvent)
Configures the validator field.


configure

public void configure(int nLength)

clear

public void clear(boolean bNotify)
Sets field to a blank string.

Specified by:
clear in interface ComponentI

isBlank

public boolean isBlank()
Returns the true if the field empty.

Specified by:
isBlank in interface ComponentI

setEnabled

public void setEnabled(boolean bState)
Enables/disables input for this field, but you can still scroll through the field.

Specified by:
setEnabled in interface ComponentI

getEnabled

public boolean getEnabled()
Specified by:
getEnabled in interface ComponentI

setDisplayLength

public void setDisplayLength(int nLength)
Sets the "display" length (in characters) for this field.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Description copied from class: java.awt.TextField
Returns the minimum size for this text field.

Specified by:
getMinimumSize in interface ComponentI

getPreferredSize

public java.awt.Dimension getPreferredSize()
Description copied from class: java.awt.TextField
Returns the preferred size for this text field.

Specified by:
getPreferredSize in interface ComponentI

setText

public void setText(java.lang.String sText)
Description copied from class: java.awt.TextComponent
Sets the text in this component to the specified string.

Specified by:
setText in interface ComponentI

setShowError

public void setShowError(boolean bState)

setPasswordMode

public void setPasswordMode()

getParentFrame

private java.awt.Frame getParentFrame()

setCustomValidator

public void setCustomValidator(com.flexstor.common.parsers.ValidatorI validator)
Specified by:
setCustomValidator in interface ComponentI

setRequired

public void setRequired(boolean bRequired)
Specified by:
setRequired in interface ComponentI

isRequired

public boolean isRequired()
Specified by:
isRequired in interface ComponentI

setPartialDisable

public void setPartialDisable(boolean bState)
Instructs this field to always "look" disabled, even when enabled.


formatCase

public void formatCase()
Formats a text field to its defined case.

Specified by:
formatCase in interface ComponentI

verify

public boolean verify(boolean bCheckRequired)
Verifies that the data in the field is valid.

Specified by:
verify in interface ComponentI

setCurrentErrorNo

private void setCurrentErrorNo(int nError)

showError

private void showError(int nError)

quietVerify

public boolean quietVerify()
Verifies the field attributes without displaying any errors.

Specified by:
quietVerify in interface ComponentI

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent e)
Processes focus. On lost focus field is verified.


addTextListener

public void addTextListener(com.flexstor.common.awt.event.FlexTextListener l)

removeTextListener

public void removeTextListener(com.flexstor.common.awt.event.FlexTextListener l)

textValueChangeBegin

public void textValueChangeBegin(java.awt.event.TextEvent e)

addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Description copied from class: java.awt.Component
Adds the specified listener to this component. This is harmless if the listener is null, but if the listener has already been registered, it will now be registered twice.


removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener l)
Description copied from class: java.awt.Component
Removes the specified listener from the component. This is harmless if the listener was not previously registered.


keyDown

public boolean keyDown(java.awt.Event e,
                       int i)
Overiding keyDown() in order to suppress some of the JClass hotkeys. The meta key (command key on Mac) is always disabled. The following hotkeys are disabled: Home (CTRL-A), End (CTRL-E), Overstrike (CTRL-O), Delete (CTRL-D), BackSpace (CTRL-H) The following hotkeys are enabled: Cut (CTRL-X), Copy (CTRL-C), Paste (CTRL-V)


processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent e)
Description copied from class: java.awt.Component
Called when a key event is dispatched and component events are enabled. This method passes the event along to any listeners that are attached.


showMsgDialog

private void showMsgDialog()

setId

public void setId(long nId)
Specified by:
setId in interface ComponentI

getId

public long getId()
Specified by:
getId in interface ComponentI

requestFocus

public void requestFocus()
Description copied from class: java.awt.Component
Request that this Component be given the keyboard input focus and that its top-level ancestor become the focused Window. For the request to be granted, the Component must be focusable, displayable and showing and the top-level Window to which it belongs must be focusable. If the request is initially denied on the basis that the top-level Window is not focusable, the request will be remembered and granted when the Window does become focused. Never assume that this Component is the focus owner until it receives a FOCUS_GAINED event. The behaviour of this method is platform-dependent. Component.requestFocusInWindow()>Component.requestFocusInWindow() 55 should be used instead.

Specified by:
requestFocus in interface ComponentI

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Description copied from class: java.awt.Component
Sets the bounding rectangle for this component to the specified values. Note that these coordinates are relative to the parent, not to the screen.

Specified by:
setBounds in interface ComponentI

textValueChanged

public void textValueChanged(java.awt.event.TextEvent arg0)
Description copied from interface: java.awt.event.TextListener
This method is called when the text being monitored changes.

Specified by:
textValueChanged in interface java.awt.event.TextListener