public class TimePicker extends JPanel implements CustomPopup.CustomPopupCloseListener
// Basic usage example:
// Create a time picker.
TimePicker timePicker = new TimePicker();
// Create a panel, and add the time picker.
JPanel panel = new JPanel();
panel.add(timePicker);
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TimePicker()
Constructor with Default Values, Create a time picker instance using the default operating
system locale and language, and default time picker settings.
|
TimePicker(TimePickerSettings settings)
Constructor with Custom Settings, Create a time picker instance using the supplied time
picker settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addTimeChangeListener(TimeChangeListener listener)
addTimeChangeListener, This adds a time change listener to this time picker.
|
void |
clear()
clear, This will clear the time picker text.
|
void |
closePopup()
closePopup, This closes the menu popup.
|
int |
getBaseline(int width,
int height)
getBaseline, This returns the baseline value of the timeTextField.
|
JButton |
getComponentDecreaseSpinnerButton()
getComponentDecreaseSpinnerButton, Returns the decrease spinner button that is used by this
time picker.
|
JButton |
getComponentIncreaseSpinnerButton()
getComponentIncreaseSpinnerButton, Returns the increase spinner button that is used by this
time picker.
|
JPanel |
getComponentSpinnerPanel()
getComponentSpinnerPanel, Returns the panel that holds the spinner buttons in this time
picker.
|
JTextField |
getComponentTimeTextField()
getComponentTimeTextField, Returns the time text field that is used by this time picker.
|
JButton |
getComponentToggleTimeMenuButton()
getComponentToggleTimeMenuButton, Returns the toggle time menu button that is used by this
time picker.
|
boolean |
getEnableArrowKeys()
getEnableArrowKeys, Returns the value of this setting.
|
TimePickerSettings |
getSettings()
getSettings, This returns the time picker settings instance.
|
String |
getText()
getText, This returns the current text that is present in the time picker text field.
|
LocalTime |
getTime()
getTime, This returns the last valid time, or returns null to represent an empty time.
|
ArrayList<TimeChangeListener> |
getTimeChangeListeners()
getTimeChangeListeners, This returns a new ArrayList, that contains any time change listeners
that are registered with this TimePicker.
|
String |
getTimeStringOrEmptyString()
getTimeStringOrEmptyString, This will return the last valid time as a string.
|
String |
getTimeStringOrSuppliedString(String emptyTimeString)
getTimeStringOrSuppliedString, This will return the last valid time as a string.
|
boolean |
isEnabled()
isEnabled, Returns true if this component is enabled, otherwise returns false.
|
boolean |
isPopupOpen()
isPopupOpen, This returns true if the time menu popup is open.
|
boolean |
isTextFieldValid()
isTextFieldValid, This returns true if, and only if, the text field contains a parsable time
or a valid empty string.
|
boolean |
isTextValid(String text)
isTextValid, This function can be used to see if the supplied text represents a "valid time"
according to the settings of this time picker.
|
boolean |
isTimeAllowed(LocalTime time)
isTimeAllowed, This checks to see if the specified time is allowed by any currently set veto
policy, and allowed by the current setting of allowEmptyTimes.
|
void |
openPopup()
openPopup, This creates and shows the menu popup.
|
void |
removeTimeChangeListener(TimeChangeListener listener)
removeTimeChangeListener, This removes the specified time change listener from this time
picker.
|
void |
setEnableArrowKeys(boolean enableArrowKeys)
setEnableArrowKeys, This sets the variable that determines if the arrow keys will be handled
by this time picker.
|
void |
setEnabled(boolean enabled)
setEnabled, This enables or disables the time picker.
|
void |
setText(String text)
setText, This sets the text of the time picker text field to the supplied value.
|
void |
setTextFieldToValidStateIfNeeded()
setTextFieldToValidStateIfNeeded,
This function will check the contents of the text field, and when needed, will set the text
to match the "last valid time" in a standardized valid format.
|
void |
setTime(LocalTime optionalTime)
setTime, This sets this time picker to the specified time.
|
void |
setTimeToNow()
setTimeToNow, This sets the time to the current time.
|
void |
togglePopup()
togglePopup, This creates and shows a menu popup.
|
String |
toString()
toString, This will return the last valid time as a string.
|
void |
zDrawTextFieldIndicators()
zDrawTextFieldIndicators, This will draw the text field indicators, to indicate to the user
the state of any text in the text field, including the validity of any time that has been
typed.
|
void |
zEventCustomPopupWasClosed(CustomPopup popup)
zEventCustomPopupWasClosed, This is called automatically whenever the CustomPopup that is
associated with this time picker is closed.
|
void |
zInternalTryChangeTimeByIncrement(int changeAmountMinutes) |
void |
zSetAppropriateTextFieldMinimumWidth()
zSetAppropriateTextFieldMinimumWidth, This sets the minimum (and preferred) width of the time
picker text field.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, 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, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, 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, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public TimePicker()
public TimePicker(TimePickerSettings settings)
public void addTimeChangeListener(TimeChangeListener listener)
public void clear()
public void closePopup()
public int getBaseline(int width, int height)
getBaseline
in class JComponent
public JButton getComponentDecreaseSpinnerButton()
public JButton getComponentIncreaseSpinnerButton()
public JPanel getComponentSpinnerPanel()
public JTextField getComponentTimeTextField()
public JButton getComponentToggleTimeMenuButton()
public boolean getEnableArrowKeys()
public LocalTime getTime()
Additional Text Validation Details: Whenever the current time picker text is not valid, the value returned by getTime() will generally not match the time picker text. The time picker can contain invalid text whenever both items (1) and (2) below are true: 1) The user has manually typed text that cannot be parsed by the parsing formats into a valid time, or the user has typed a time that is vetoed by a current veto policy, or the user has cleared (or left only whitespace) in the text when allowEmptyTimes is false. 2) The time picker text field has continued to have focus, and therefore the automatic validation (revert/commit) process has not yet occurred.
public ArrayList<TimeChangeListener> getTimeChangeListeners()
public String getTimeStringOrEmptyString()
public String getTimeStringOrSuppliedString(String emptyTimeString)
public TimePickerSettings getSettings()
public String getText()
public boolean isEnabled()
public boolean isPopupOpen()
public boolean isTextFieldValid()
public boolean isTextValid(String text)
public boolean isTimeAllowed(LocalTime time)
public void openPopup()
public void removeTimeChangeListener(TimeChangeListener listener)
public void setEnableArrowKeys(boolean enableArrowKeys)
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public void setText(String text)
public void setTextFieldToValidStateIfNeeded()
public void setTime(LocalTime optionalTime)
public void setTimeToNow()
public String toString()
public void togglePopup()
public void zDrawTextFieldIndicators()
public void zEventCustomPopupWasClosed(CustomPopup popup)
zEventCustomPopupWasClosed
in interface CustomPopup.CustomPopupCloseListener
public void zInternalTryChangeTimeByIncrement(int changeAmountMinutes)
public void zSetAppropriateTextFieldMinimumWidth()
Copyright © 2018. All rights reserved.