Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class MaterialTimePicker

  1. Object
  2. Component
  3. Container
  4. MaterialTimePicker

ImplementsAnimation, Editable, InternalPickerWidget, Iterable<Component>, StyleListener

A time picker in the Material 3 style: the hour and the minute in large type over a clock face. The hand is dragged to the hour, the face then turns to minutes, and a keyboard button swaps the face for two text fields.

A Picker opens one in a dialog when the theme constant pickerStyle is material. It is a component like any other and can be placed in a form directly. The value is an Integer, the minutes since midnight, as it is for the time of a Picker.

With setShowMeridiem(true) the face has twelve hours and AM and PM beside the time; without, it has two rings, the afternoon inside.

The hours of a Material time picker The minutes Twenty four hours

Under a mouse the number the pointer is over is marked. The hand follows a finger as it is dragged, and turns by the shorter way round to a time that is set any other way: the minutes after an hour is chosen, a time typed in, a call to setTime.

The hand turning from ten to two, as four stopped frames

Styling

PickerMaterialOverline is the small title. PickerMaterialTimeField is the hour and the minute, its selected style the one the face is showing, and PickerMaterialTimeSeparator the colon between them. PickerMaterialPeriod is AM and PM. PickerMaterialDial is the face: its background the disc and its foreground the numbers, and its selected style the hand, with the foreground the number under it. Its disabled style is an hour outside the range. PickerMaterialButton is the keyboard button and PickerMaterialField a text field.

Constructors

public MaterialTimePicker()A picker showing midnight on a 24 hour face.

Methods

public int getHour()The hour of the day, 0 to 23.
public int getMinute()
public void setTime(int hourOfDay, int minuteOfHour)Sets the time.
public Object getValue()The minutes since midnight, as an Integer.
public void setValue(Object value)Sets the time from the minutes since midnight.
public boolean isShowMeridiem()Whether the face has twelve hours with AM and PM beside the time.
public void setShowMeridiem(boolean v)
public void setMinuteStep(int step)The minutes the hand stops at: 5 for every five minutes, 1 for all.
public int getMinuteStep()
public void setHourRange(int min, int max)The hours that can be chosen: from min up to but not max.
public void setTitle(String title)The small title over the time: “Select time” unless set.
public String getTitle()
public void addActionListener(ActionListener l)Told when the user chooses another time.
public void removeActionListener(ActionListener l)
public boolean isInputMode()Whether the time is typed and not picked from the face.
public void setInputMode(boolean v)
public Button getInputModeButton()The button that swaps the face for text fields.
public void setAnimationTime(long millis)Stops the clock the hand turns by at a time, for a screenshot of the turn or a test of it.

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, deinitialize, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

MaterialTimePicker

public MaterialTimePicker()
A picker showing midnight on a 24 hour face.

Method details

getHour

public int getHour()
The hour of the day, 0 to 23.

getMinute

public int getMinute()

setTime

public void setTime(int hourOfDay, int minuteOfHour)
Sets the time. The hour is of the day, 0 to 23, whatever the face shows; an hour outside the range is brought to the nearest one in it. The minute is kept as it is given: the step is where the hand stops when it is turned, and a time that is only looked at is not changed by having been shown.

getValue

public Object getValue()
The minutes since midnight, as an Integer.

Returns

the selection, in whatever type this implementation documents; never null once the widget has been laid out

setValue

public void setValue(Object value)
Sets the time from the minutes since midnight. Anything that is not an Integer is ignored.

Parameters

value Object
the new selection, in the type this implementation documents. A value outside the widget’s range is clamped into it.

isShowMeridiem

public boolean isShowMeridiem()
Whether the face has twelve hours with AM and PM beside the time.

setShowMeridiem

public void setShowMeridiem(boolean v)

setMinuteStep

public void setMinuteStep(int step)
The minutes the hand stops at: 5 for every five minutes, 1 for all.

getMinuteStep

public int getMinuteStep()

setHourRange

public void setHourRange(int min, int max)
The hours that can be chosen: from min up to but not max. A negative min removes the limit.

setTitle

public void setTitle(String title)
The small title over the time: “Select time” unless set.

getTitle

public String getTitle()

addActionListener

public void addActionListener(ActionListener l)
Told when the user chooses another time.

removeActionListener

public void removeActionListener(ActionListener l)

isInputMode

public boolean isInputMode()
Whether the time is typed and not picked from the face.

setInputMode

public void setInputMode(boolean v)

getInputModeButton

public Button getInputModeButton()
The button that swaps the face for text fields. It is under the face until something takes it: a dialog puts it beside its own buttons.

setAnimationTime

public void setAnimationTime(long millis)
Stops the clock the hand turns by at a time, for a screenshot of the turn or a test of it. A negative value returns to the clock.