|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
com.metamatrix.toolbox.ui.widget.TextFieldWidget
public class TextFieldWidget
This class is intended to be used everywhere within the application that a single-line text Textor (similar to JTextField) needs to be displayed. It provides the following features:
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 |
BACKGROUND_COLOR_PROPERTY
|
static java.lang.String |
COLUMN_WIDTH_CHARACTER_PROPERTY
|
static java.lang.String |
FOREGROUND_COLOR_PROPERTY
|
static java.lang.String |
INVALID_BACKGROUND_COLOR_PROPERTY
|
static java.lang.String |
INVALID_FOREGROUND_COLOR_PROPERTY
|
static java.lang.String |
PROPERTY_PREFIX
|
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 com.metamatrix.toolbox.ui.widget.text.TextConstants |
---|
IS_MODIFIED_PROPERTY, IS_VALID_PROPERTY, MAXIMUM_LENGTH_PROPERTY, TEXT_PROPERTY |
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 | |
---|---|
TextFieldWidget()
Creates a blank field with no constraints. |
|
TextFieldWidget(int characters)
Creates a blank field wide enough to display the specified number of characters. |
|
TextFieldWidget(java.lang.String text)
Creates a field populated with the specified text, and wide enough to display the text. |
|
TextFieldWidget(java.lang.String text,
int characters)
Creates a field populated with the specified text, and wide enough to display the specified number of characters. |
Method Summary | |
---|---|
protected void |
buildContextMenu()
Builds a context menu containing a default set of options to cut, copy, and paste. |
boolean |
commit()
Commits any new text set on the model. |
protected javax.swing.text.Document |
createDefaultModel()
Overridden to create a DefaultTextFieldModel instead of the default model created by JTextField. |
javax.swing.JToolTip |
createToolTip()
|
void |
cut()
|
int |
getColumnWidth()
|
char |
getColumnWidthCharacter()
|
javax.swing.JPopupMenu |
getContextMenu()
|
java.awt.Dimension |
getMaximumSize()
Overridden to force the field's maximum height to match its preferred height. |
java.awt.Dimension |
getMinimumSize()
Overridden to force the field's minimum height to match its preferred height. |
java.awt.Dimension |
getPreferredSize()
Overridden to force the field's preferred height to be immutable. |
protected void |
initializeTextFieldWidget()
Builds a context menu containing a default set of options to cut, copy, and paste. |
boolean |
isClipTipEnabled()
|
boolean |
isContextMenuEnabled()
|
boolean |
isErrorTipEnabled()
|
boolean |
isTextValid()
|
void |
paste()
|
void |
rollback()
Rollsback to the previous value in the model. |
void |
scrollRectToVisible(java.awt.Rectangle rectangle)
Overridden to provide a tooltip containing the full text whenever the text is clipped. |
void |
selectText()
Selects all of the current text. |
void |
setClipTipEnabled(boolean isClipTipEnabled)
Sets whether a tooltip will be displayed containing the full text whenever the text is clipped. |
protected void |
setClipTipText()
Sets a tooltip containing the full text whenever the text is clipped. |
void |
setColumnWidth(int width)
Setting the column width to zero will cause the column width to be recalculated from the current column width character. |
void |
setColumnWidthCharacter(char character)
Sets the character to use when calculating pixel widths that are based upon a character count. |
void |
setContextMenuEnabled(boolean isMenuEnabled)
Sets whether a pop-up context menu will be displayed when the user right-clicks the mouse. |
void |
setErrorTipEnabled(boolean isErrorTipEnabled)
Sets whether a tooltip will be displayed when the text is marked as invalid. |
void |
setFont(java.awt.Font font)
|
void |
setInvalidCharacters(java.lang.String invalidCharacters)
A convenience method to set the list of invalid characters in the model. |
void |
setMaximumSize(java.awt.Dimension size)
Overridden to force the field's maximum height to match its preferred height. |
void |
setMaximumWidth(int width)
Sets the maximum pixel width of the field. |
void |
setMinimumSize(java.awt.Dimension size)
Overridden to force the field's minimum height to match its preferred height. |
void |
setMinimumWidth(int width)
Sets the minimum pixel width of the field. |
void |
setPreferredSize(java.awt.Dimension size)
Overridden to force the field's preferred height to be immutable. |
void |
setPreferredWidth(int width)
Sets the preferred pixel width of the field. |
void |
setText(java.lang.String text)
|
void |
setValidCharacters(java.lang.String validCharacters)
A convenience method to set the list of valid characters in the model. |
java.lang.String |
toString()
|
protected void |
validateModel()
Determines if the model is valid. |
Methods inherited from class javax.swing.JTextField |
---|
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, setAction, setActionCommand, setColumns, setDocument, setHorizontalAlignment, setScrollOffset |
Methods inherited from class javax.swing.text.JTextComponent |
---|
addCaretListener, addInputMethodListener, addKeymap, copy, 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, 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, setUI, updateUI, viewToModel, write |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, 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, setNextFocusableComponent, setOpaque, 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, 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 PROPERTY_PREFIX
public static final java.lang.String BACKGROUND_COLOR_PROPERTY
public static final java.lang.String FOREGROUND_COLOR_PROPERTY
public static final java.lang.String INVALID_BACKGROUND_COLOR_PROPERTY
public static final java.lang.String INVALID_FOREGROUND_COLOR_PROPERTY
public static final java.lang.String COLUMN_WIDTH_CHARACTER_PROPERTY
Constructor Detail |
---|
public TextFieldWidget()
public TextFieldWidget(java.lang.String text)
text
- The initial textpublic TextFieldWidget(int characters)
characters
- The width of the fieldpublic TextFieldWidget(java.lang.String text, int characters)
text
- The initial textcharacters
- The width of the fieldMethod Detail |
---|
protected void buildContextMenu()
public void paste()
paste
in class javax.swing.text.JTextComponent
public void cut()
cut
in class javax.swing.text.JTextComponent
public boolean commit()
protected javax.swing.text.Document createDefaultModel()
createDefaultModel
in class javax.swing.JTextField
public javax.swing.JToolTip createToolTip()
createToolTip
in class javax.swing.JComponent
public int getColumnWidth()
getColumnWidth
in class javax.swing.JTextField
public char getColumnWidthCharacter()
public javax.swing.JPopupMenu getContextMenu()
public java.awt.Dimension getMaximumSize()
getMaximumSize
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JTextField
protected void initializeTextFieldWidget()
public boolean isClipTipEnabled()
public boolean isContextMenuEnabled()
public boolean isErrorTipEnabled()
public boolean isTextValid()
public void rollback()
public void scrollRectToVisible(java.awt.Rectangle rectangle)
scrollRectToVisible
in class javax.swing.JTextField
JTextField.scrollRectToVisible(Rectangle)
,
setClipTipText()
public void selectText()
public void setClipTipEnabled(boolean isClipTipEnabled)
isClipTipEnabled
- True if a tooltip should be displayed when text is clippedprotected void setClipTipText()
public void setColumnWidth(int width)
width
- The preferred pixel widthpublic void setColumnWidthCharacter(char character)
public void setContextMenuEnabled(boolean isMenuEnabled)
isMenuEnabled
- True if a menu should be displayedpublic void setErrorTipEnabled(boolean isErrorTipEnabled)
isErrorTipEnabled
- True if a tooltip should be displayed when text is marked as invalidpublic void setFont(java.awt.Font font)
setFont
in class javax.swing.JTextField
public void setInvalidCharacters(java.lang.String invalidCharacters) throws java.text.ParseException
invalidCharacters
- A list of invalid characters and/or character ranges
java.text.ParseException
- If a syntax error was found while parsing invalidCharactersDefaultTextFieldModel.setInvalidCharacters(String)
public void setMaximumSize(java.awt.Dimension size)
setMaximumSize
in class javax.swing.JComponent
JComponent.setMaximumSize(Dimension)
public void setMaximumWidth(int width)
width
- The maximum pixel widthpublic void setMinimumSize(java.awt.Dimension size)
setMinimumSize
in class javax.swing.JComponent
JComponent.setMinimumSize(Dimension)
public void setMinimumWidth(int width)
width
- The minimum pixel widthpublic void setPreferredSize(java.awt.Dimension size)
setPreferredSize
in class javax.swing.JComponent
JComponent.setPreferredSize(Dimension)
public void setPreferredWidth(int width)
width
- The preferred pixel widthpublic void setText(java.lang.String text)
setText
in class javax.swing.text.JTextComponent
public void setValidCharacters(java.lang.String validCharacters) throws java.text.ParseException
validCharacters
- A list of valid characters and/or character ranges
java.text.ParseException
- If a syntax error was found while parsing validCharactersDefaultTextFieldModel.setValidCharacters(String)
public java.lang.String toString()
toString
in class java.awt.Component
protected void validateModel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |