java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
org.bzdev.swing.VTextField
org.bzdev.swing.TimeTextField
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable,SwingConstants
Text field constrained to allow time intervals.
The intervals can be SECONDS (including decimal values to
millisecond precision), MINUTES:SECONDS and HOURS:MINUTES:SECONDS.
In addition, the text field can be configures to accept a
single-character input containing '?' to indicate that the
application will interactively determine the time interval, and '*'
to indicate that the time interval is indefinite (i.e., not
specified by the user).
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.bzdev.swing.VTextField
VTextField.ErrorPolicyNested 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
FieldsModifier and TypeFieldDescriptionstatic final intIndicate an indefinite interval.static final intIndicate a queried time interval.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
ConstructorsConstructorDescriptionClass constructor.TimeTextField(int ncols) Class constructor specifying the field size..TimeTextField(int ncols, TimeTextField.Mode mode) Constructor specifying the field size and mode.TimeTextField(String text) Constructor giving an initial string.TimeTextField(String text, int ncols) Constructor giving an initial string and field size.TimeTextField(String text, int ncols, TimeTextField.Mode mode) Constructor giving an initial string, field size and mode.TimeTextField(String text, TimeTextField.Mode mode) Constructor giving an initial string and mode.TimeTextField(Document doc, String text, int ncols) Class constructor for a document model, initial string and field size.TimeTextField(Document doc, String text, int ncols, TimeTextField.Mode mode) Constructor for a document model, initial string, field size, and mode. -
Method Summary
Modifier and TypeMethodDescriptionlonggetValue()Get the text field's value.protected voidAccept input.static longParse a string representing the a time interval The format is [[DIGITS:]DIGITS:]DIGITS[.DIGITS] where DIGITS is a series of one or more digits.voidsetDefaultValue(long value) Set the default value when the text-string is empty.voidsetValue(long value) Set the value of the text field.Methods inherited from class org.bzdev.swing.VTextField
fireActionPerformed, getAllowEmptyTextField, getValidatedText, handleError, removeActionListener, setAllowEmptyTextField, setErrorPolicy, setInputVerifier, setTextMethods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, 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, 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, getMaximumSize, 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, 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
-
Field Details
-
INDEFINITE
public static final int INDEFINITEIndicate an indefinite interval. This value for the field indicates that the time interval is indefinite - until the application quits or stops the operation for which the time interval is used.- See Also:
-
QUERY
public static final int QUERYIndicate a queried time interval. This value for the field indicates that the caller is expected to determine the time interval by some interactive means.- See Also:
-
-
Constructor Details
-
TimeTextField
public TimeTextField()Class constructor. -
TimeTextField
Class constructor for a document model, initial string and field size.- Parameters:
doc- the document model (must be an AbstractDocument)text- the initial textncols- the number of columns in the text field.
-
TimeTextField
public TimeTextField(int ncols) Class constructor specifying the field size..- Parameters:
ncols- the number of columns in the text field.
-
TimeTextField
Constructor giving an initial string.- Parameters:
text- the initial text
-
TimeTextField
Constructor giving an initial string and field size.- Parameters:
text- the initial textncols- the number of columns in the text field.
-
TimeTextField
Constructor for a document model, initial string, field size, and mode.- Parameters:
doc- the document model (must be an AbstractDocument)text- the initial textncols- the number of columns in the text field.mode- Mode.PLAIN, Mode.QUERY, Mode.INDEFINITE, or Mode.QUERY_AND_INDEFINITE to specify use of a single-character value- See Also:
-
TimeTextField
Constructor specifying the field size and mode.- Parameters:
ncols- the number of columns in the text field.mode- Mode.PLAIN, Mode.QUERY, Mode.INDEFINITE, or Mode.QUERY_AND_INDEFINITE to specify use of a single-character value- See Also:
-
TimeTextField
Constructor giving an initial string and mode.- Parameters:
text- the initial textmode- Mode.PLAIN, Mode.QUERY, Mode.INDEFINITE, or Mode.QUERY_AND_INDEFINITE to specify use of a single-character value- See Also:
-
TimeTextField
Constructor giving an initial string, field size and mode.- Parameters:
text- the initial textncols- the number of columns in the text fieldmode- Mode.PLAIN, Mode.QUERY, Mode.INDEFINITE, or Mode.QUERY_AND_INDEFINITE to specify use of a single-character value- See Also:
-
-
Method Details
-
parseTime
Parse a string representing the a time interval The format is [[DIGITS:]DIGITS:]DIGITS[.DIGITS] where DIGITS is a series of one or more digits. The optional part before and including the first colon represents hours, and the optional part before the second colon represents minutes. The next secion is a decimal number giving the time in seconds.- Parameters:
value- the string to parse- Returns:
- the time in milliseconds
- Throws:
Exception- an exception occurred
-
onAccepted
Description copied from class:VTextFieldAccept input. This method will be called when input is accepted, either by terminating the input with the "Enter" or "Return" key, or by changing the focus to another component in this application. Note that selecting a window in a separate application may not trigger this method.The default method does nothing, but may be overridden to perform some operation when the value of the text field changes to a new accepted value. During error correction, this may happen multiple times. It can also happen if the method
VTextField.setText(String)is called. While this method can throw an exception, it is called in such a way that the exception will normally be caught by this class' methods and processed silently if at all.When an instance of this class is constructed and the text field is empty, an initial call to this method is suppressed.
- Overrides:
onAcceptedin classVTextField- Throws:
Exception- an error occurred
-
setValue
public void setValue(long value) Set the value of the text field.- Parameters:
value- the text-field's value (a non-negative integer, TimeTextField.QUERY, or TimeTextField.INDEFINITE)- Throws:
IllegalArgumentException- the argument is out of range
-
getValue
public long getValue()Get the text field's value. The value will be in units of milliseconds, with -1 indicting that the value is indefinite and -2 indicating that the user is asking for a value. Values representing times are always positive.- Returns:
- the value of the text field, or the default value when the text field is empty
-
setDefaultValue
public void setDefaultValue(long value) Set the default value when the text-string is empty. The value may be any integer larger than -3, although values representing a time will always be non-negative. This allows getValue to return a negative value as an indication that the field is indefinite (-1), or that the user is asking for a value (-2).- Parameters:
value- the default value to use
-