Package megamek.client.ui.widget
Class VerifiableTextField
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
megamek.client.ui.widget.VerifiableTextField
- All Implemented Interfaces:
FocusListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,Scrollable,SwingConstants
This is an extension of the
JTextField that includes the capacity for DataVerifier objects to be
added. These verifiers will be checked when the component loses focus and if any fail, the background of the field
will be turned red and the tool tip updated with information on what verifier was failed.- Since:
- 3/14/14 1:08 PM
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextFieldNested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class javax.swing.JTextField
notifyActionFields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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 -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.VerifiableTextField(int columns) VerifiableTextField(int columns, boolean isRequired, boolean selectOnFoc, DataVerifier ver) VerifiableTextField(String text) Deprecated, for removal: This API element is subject to removal in a future version.VerifiableTextField(String text, int columns) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVerifier(DataVerifier verifier) Adds a newDataVerifierto validate this field's data.voidvoidgetAsInt()static ColorReturns an "invalid background" color.Deprecated, for removal: This API element is subject to removal in a future version.booleanbooleanDeprecated, for removal: This API element is subject to removal in a future version.booleanbooleanvoidremoveVerifier(DataVerifier verifier) Deprecated, for removal: This API element is subject to removal in a future version.voidsetOldToolTip(String oldToolTip) voidsetRequired(boolean required) Marks this text field as required/unrequired and sets up/removes aVerifyNotNullOrEmptyverifier.voidsetSelectAllTextOnGotFocus(boolean selectAllTextOnGotFocus) booleanCompares the text field's value to the list ofDataVerifierobjects to ensure the validity of the data.Compares the text field's value to the list ofDataVerifierobjects to ensure the validity of the data.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, setScrollOffsetMethods 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, modelToView2D, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, viewToModel2D, writeMethods 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
VerifiableTextField
Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
HeadlessException
-
VerifiableTextField
@Deprecated(since="0.51.0", forRemoval=true) public VerifiableTextField(String text) throws HeadlessException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
HeadlessException
-
VerifiableTextField
- Throws:
HeadlessException
-
VerifiableTextField
- Throws:
HeadlessException
-
VerifiableTextField
public VerifiableTextField(int columns, boolean isRequired, boolean selectOnFoc, DataVerifier ver) throws HeadlessException - Throws:
HeadlessException
-
-
Method Details
-
isSelectAllTextOnGotFocus
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- TRUE if all the text in this control will be automatically selected when it receives the focus.
-
setSelectAllTextOnGotFocus
public void setSelectAllTextOnGotFocus(boolean selectAllTextOnGotFocus) - Parameters:
selectAllTextOnGotFocus- Set TRUE if all the text in this control will be automatically selected when it receives the focus.
-
isTextNullOrEmpty
public boolean isTextNullOrEmpty()- Returns:
- TRUE if the field's text value is NULL or an empty
String.
-
isTextNumeric
public boolean isTextNumeric()- Returns:
- TRUE if the field's text value is a valid number.
-
isRequired
public boolean isRequired()- Returns:
- TRUE if this field is not allowed to be null or empty.
-
setRequired
public void setRequired(boolean required) Marks this text field as required/unrequired and sets up/removes aVerifyNotNullOrEmptyverifier. Also sets the background color blue if it is required.- Parameters:
required- TRUE if this field is required to have data.
-
focusGained
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
- Specified by:
focusLostin interfaceFocusListener
-
addVerifier
Adds a newDataVerifierto validate this field's data.- Parameters:
verifier- The newDataVerifierto be added.
-
removeVerifier
Deprecated, for removal: This API element is subject to removal in a future version.Removes the givenDataVerifierfrom this field.- Parameters:
verifier- TheDataVerifierto be removed.
-
verifyTextS
Compares the text field's value to the list ofDataVerifierobjects to ensure the validity of the data. If the text value passes all validation checks, a NULL value will be returned. Otherwise, a description of the failed validation will be returned. Does not verify if the field is disabled.- Returns:
- NULL if the text in the field is valid. A description of the failure otherwise.
-
verifyText
public boolean verifyText()Compares the text field's value to the list ofDataVerifierobjects to ensure the validity of the data.- Returns:
- true if the text in the field is valid.
-
getAsInt
-
getOldToolTip
Deprecated, for removal: This API element is subject to removal in a future version. -
setOldToolTip
-
getInvalidColor
Returns an "invalid background" color. It is mixed from the GUIPreferences WarningColor and the UIManager text field background color. -
getMaximumSize
- Overrides:
getMaximumSizein classJComponent
-