|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.text.JTextComponent javax.swing.JTextField com.isti.util.gui.FilteredJTextField
public class FilteredJTextField
Class FilteredJTextField is an extension of 'JTextField' which only allows certain characters to be entered into it. Static strings of allowed characters for numeric types (i.e. INTEGER_CHARS) are provided. To construct a text field that only allows valid floating point numeric values (including the 'e' exponent) to be entered, the following constructor could be used: new FilteredJTextField("",5,SIGNED_EFLOAT_CHARS,true) It will initially be empty and have a column size of 5. The 'true' flag indicates that only valid numeric values are allowed, so numeric rules (such as only one decimal point, etc) are applied.
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.DropLocation, 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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.lang.String |
ALPHA_CAP_CHARS
Static string containing the upper-case characters 'A' through 'Z'. |
static java.lang.String |
ALPHA_CHARS
Static string containing the characters 'A' through 'Z' and 'a' through 'z'. |
static java.lang.String |
ALPHA_LOW_CHARS
Static string containing the lower-case characters 'a' through 'z'. |
static java.lang.String |
ALPHANUMERIC_CHARS
Static string containing the characters 'A' through 'Z', 'a' through 'z' and '0' though '9'. |
static java.lang.String |
EFLOAT_CHARS
Static string containing the numeric characters '0' through '9', the decimal point character '.' and the exponent characters 'e' and 'E'. |
static java.lang.String |
FLOAT_CHARS
Static string containing the numeric characters '0' through '9' and the decimal point character '.'. |
static java.lang.String |
HEX_ALPHA_CAP_CHARS
Static string containing the upper-case HEX characters 'A' through 'F'. |
static java.lang.String |
HEX_ALPHA_LOW_CHARS
Static string containing the lower-case HEX characters 'a' through 'f'. |
static java.lang.String |
HEX_CHARS
Static string containing the HEX characters. |
static java.lang.String |
INTEGER_CHARS
Static string containing the numeric characters '0' through '9'. |
static java.lang.String |
SIGNED_EFLOAT_CHARS
Static string containing the numeric characters '0' through '9', the decimal point character '.', the exponent characters 'e' and 'E', and the sign characters '-' and '+'. |
static java.lang.String |
SIGNED_FLOAT_CHARS
Static string containing the numeric characters '0' through '9', the decimal point character '.' and the sign characters '-' and '+'. |
static java.lang.String |
SIGNED_INT_CHARS
Static string containing the numeric characters '0' through '9' and the sign characters '-' and '+'. |
static java.lang.String |
TOD_CHARS
Static string containing the characters needed to specify a time of day ('0' through '9', ':' and '.'). |
static java.lang.String |
WILDCARD_ALL_CHAR
Static string containing the asterisk wildcard character. |
static java.lang.String |
WILDCARD_CHARS
Static string containing asterisk and question-mark wildcard characters. |
static java.lang.String |
WILDCARD_SINGLE_CHAR
Static string containing the question-mark wildcard character. |
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 | |
---|---|
FilteredJTextField()
Creates a new 'FilteredJTextField' object. |
|
FilteredJTextField(int maxNumChars)
Creates a new 'FilteredJTextField' object. |
|
FilteredJTextField(int columns,
java.lang.String allowedChars)
Creates a new 'FilteredJTextField' object. |
|
FilteredJTextField(java.lang.String text)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int maxNumChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int columns,
boolean isFloatFlag,
boolean isUnsignedFlag)
Creates a new 'FilteredJTextField' object initialized with the given text for numeric values. |
|
FilteredJTextField(java.lang.String text,
int columns,
java.lang.String allowedChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int columns,
java.lang.String allowedChars,
boolean numericFlag)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int columns,
java.lang.String allowedChars,
boolean numericFlag,
int maxNumChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int columns,
java.lang.String specialChars,
boolean numericFlag,
int maxNumChars,
boolean allowFlag)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
int columns,
java.lang.String allowedChars,
int maxNumChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
java.lang.String allowedChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
java.lang.String allowedChars,
boolean numericFlag)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
java.lang.String allowedChars,
boolean numericFlag,
int maxNumChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
|
FilteredJTextField(java.lang.String text,
java.lang.String allowedChars,
int maxNumChars)
Creates a new 'FilteredJTextField' object initialized with the given text. |
Method Summary | |
---|---|
static java.lang.String |
getAllowedNumberChars(boolean isFloatFlag,
boolean isUnsignedFlag)
Gets the allowed number characters. |
int |
getIntegerValue()
Gets the integer value represented by this text field. |
java.lang.Comparable |
getMaxValueObj()
Returns the maximum value to be allowed for numeric entries, or null if no value has been entered. |
FilteredJTextField |
setMaxValue(byte val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(java.lang.Comparable compObj)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(double val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(float val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(int val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(long val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
FilteredJTextField |
setMaxValue(short val)
Sets a maximum value to be allowed for numeric entries (only used if the 'numericFlag' is true). |
Methods inherited from class javax.swing.JTextField |
---|
actionPropertyChanged, 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, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, 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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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 |
---|
public static final java.lang.String INTEGER_CHARS
public static final java.lang.String HEX_ALPHA_CAP_CHARS
public static final java.lang.String HEX_ALPHA_LOW_CHARS
public static final java.lang.String HEX_CHARS
public static final java.lang.String SIGNED_INT_CHARS
public static final java.lang.String FLOAT_CHARS
public static final java.lang.String SIGNED_FLOAT_CHARS
public static final java.lang.String EFLOAT_CHARS
public static final java.lang.String SIGNED_EFLOAT_CHARS
public static final java.lang.String ALPHA_CAP_CHARS
public static final java.lang.String ALPHA_LOW_CHARS
public static final java.lang.String ALPHA_CHARS
public static final java.lang.String ALPHANUMERIC_CHARS
public static final java.lang.String TOD_CHARS
public static final java.lang.String WILDCARD_ALL_CHAR
public static final java.lang.String WILDCARD_SINGLE_CHAR
public static final java.lang.String WILDCARD_CHARS
Constructor Detail |
---|
public FilteredJTextField()
public FilteredJTextField(java.lang.String text)
text
- text stringpublic FilteredJTextField(java.lang.String text, java.lang.String allowedChars, boolean numericFlag)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.numericFlag
- true if only valid numeric data is to be allowed.public FilteredJTextField(java.lang.String text, java.lang.String allowedChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.public FilteredJTextField(java.lang.String text, int columns, boolean isFloatFlag, boolean isUnsignedFlag)
text
- the initial text for the field.columns
- the number of the columns for the field.isFloatFlag
- true if floating point number.isUnsignedFlag
- true if unsigned number.public FilteredJTextField(java.lang.String text, int columns, java.lang.String allowedChars, boolean numericFlag)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.columns
- the number of the columns for the field.numericFlag
- true if only valid numeric data is to be allowed.public FilteredJTextField(java.lang.String text, int columns, java.lang.String allowedChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.columns
- the number of the columns for the field.public FilteredJTextField(int columns, java.lang.String allowedChars)
allowedChars
- a String of characters allowed to be entered
into the field.columns
- the number of the columns for the field.public FilteredJTextField(int maxNumChars)
maxNumChars
- maximum number of characters allowed (or 0
for no limit).public FilteredJTextField(java.lang.String text, int maxNumChars)
text
- text stringmaxNumChars
- maximum number of characters allowed (or 0
for no limit).public FilteredJTextField(java.lang.String text, java.lang.String allowedChars, boolean numericFlag, int maxNumChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.numericFlag
- true if only valid numeric data is to be allowed.maxNumChars
- maximum number of characters allowed (or 0
for no limit).public FilteredJTextField(java.lang.String text, java.lang.String allowedChars, int maxNumChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.maxNumChars
- maximum number of characters allowed (or 0
for no limit).public FilteredJTextField(java.lang.String text, int columns, java.lang.String allowedChars, boolean numericFlag, int maxNumChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.columns
- the number of the columns for the field.numericFlag
- true if only valid numeric data is to be allowed.maxNumChars
- maximum number of characters allowed (or 0
for no limit).public FilteredJTextField(java.lang.String text, int columns, java.lang.String specialChars, boolean numericFlag, int maxNumChars, boolean allowFlag)
text
- the initial text for the field.specialChars
- a String of characters allowed (or not) to be entered
into the field.columns
- the number of the columns for the field.numericFlag
- true if only valid numeric data is to be allowed.maxNumChars
- maximum number of characters allowed (or 0
for no limit).allowFlag
- true to allow only the special characters, false to not
allow the special characters.public FilteredJTextField(java.lang.String text, int columns, java.lang.String allowedChars, int maxNumChars)
text
- the initial text for the field.allowedChars
- a String of characters allowed to be entered
into the field.columns
- the number of the columns for the field.maxNumChars
- maximum number of characters allowed (or 0
for no limit).Method Detail |
---|
public static final java.lang.String getAllowedNumberChars(boolean isFloatFlag, boolean isUnsignedFlag)
isFloatFlag
- true if floating point number.isUnsignedFlag
- true if unsigned number.
public FilteredJTextField setMaxValue(java.lang.Comparable compObj)
compObj
- a "maximum" value object that implements the
'Comparable' interface (or null for no maximum).
public int getIntegerValue()
public java.lang.Comparable getMaxValueObj()
public FilteredJTextField setMaxValue(int val)
val
- maximum value to be allowed.
public FilteredJTextField setMaxValue(long val)
val
- maximum value to be allowed.
public FilteredJTextField setMaxValue(short val)
val
- maximum value to be allowed.
public FilteredJTextField setMaxValue(byte val)
val
- maximum value to be allowed.
public FilteredJTextField setMaxValue(double val)
val
- maximum value to be allowed.
public FilteredJTextField setMaxValue(float val)
val
- maximum value to be allowed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |