# Class PickerComponent

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.ui.InputComponent
com.codename1.ui.PickerComponent

All Implemented Interfaces:
  `Animation, Editable, StyleListener, Iterable<Component>`

public class PickerComponent extends InputComponent

A picker component similar to `com.codename1.ui.TextComponent` that adapts to native UI conventions and leverages the `com.codename1.ui.spinner.Picker` API. See the docs for `com.codename1.ui.InputComponent` for more options and coverage.

The following code demonstrates a simple set of inputs and validation as it appears in iOS, Android and with validation errors

    TextModeLayout tl = new TextModeLayout(3, 2);
    Form f = new Form("Pixel Perfect", tl);

    TextComponent title = new TextComponent().label("Title");
    TextComponent price = new TextComponent().label("Price");
    TextComponent location = new TextComponent().label("Location");
    PickerComponent date = PickerComponent.createDate(new Date()).label("Date");
    TextComponent description = new TextComponent().label("Description").multiline(true);

    Validator val = new Validator();
    val.addConstraint(title, new LengthConstraint(2));
    val.addConstraint(price, new NumericConstraint(true));

    f.add(tl.createConstraint().widthPercentage(60), title);
    f.add(tl.createConstraint().widthPercentage(40), date);
    f.add(location);
    f.add(price);
    f.add(tl.createConstraint().horizontalSpan(2), description);
    f.setEditOnShow(title.getField());

    f.show();

- ## Field Summary

  ### Fields inherited from class Component

  `BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `PickerComponent()`
  Allows subclassing the picker component for customization

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static PickerComponent`
  `createDate(Date date)`
  Creates a date picker component
  `static PickerComponent`
  `createDateTime(Date date)`
  Creates a date + time picker component
  `static PickerComponent`
  `createDurationHoursMinutes(int hours, int minutes)`
  Creates a duration hours + minutes picker component
  `static PickerComponent`
  `createDurationMinutes(int ms)`
  Creates a duration minutes picker component
  `protected Picker`
  `createPickerInstance()`
  Allows developers to subclass the Picker component instance to customize behaviors of the subclass
  `static PickerComponent`
  `createStrings(String... values)`
  Creates a strings picker component
  `static PickerComponent`
  `createTime(int minutes)`
  Creates a time picker component
  `PickerComponent`
  `errorMessage(String errorMessage)`
  Overridden for covariant return type Sets the text of the error label
  `final Component`
  `getEditor()`
  Returns the editor component e.g.
  `Picker`
  `getPicker()`
  Returns the picker instance
  `PickerComponent`
  `label(String text)`
  Overridden for covariant return type Sets the text of the label
  `PickerComponent`
  `onTopMode(boolean onTopMode)`
  Overridden for covariant return type Sets the on top mode which places the label above the text when true.

  ### Methods inherited from class InputComponent

  `action, actionAsButton, actionClick, actionText, actionUIID, calcPreferredSize, createErrorLabel, descriptionMessage, getAction, getActionText, getActionUIID, getPropertyValue, group, initInput, isActionAsButton, isMultiLineErrorMessage, isOnTopMode, setMultiLineErrorMessage, setPropertyValue`

  ### Methods inherited from class Container

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

  ### Methods inherited from class Component

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

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### PickerComponent

    protected PickerComponent()
    Allows subclassing the picker component for customization

- ## Method Details

  - ### createStrings

    public static PickerComponent createStrings(String... values)

    Creates a strings picker component

    ###### Parameters

    - `values`: the values for the picker

    ###### Returns

    a strings version of the picker component

  - ### createDate

    public static PickerComponent createDate(Date date)

    Creates a date picker component

    ###### Parameters

    - `date`: the initial date in the picker

    ###### Returns

    a date version of the picker component

  - ### createDateTime

    public static PickerComponent createDateTime(Date date)

    Creates a date + time picker component

    ###### Parameters

    - `date`: the initial date in the picker

    ###### Returns

    a date + time version of the picker component

  - ### createTime

    public static PickerComponent createTime(int minutes)

    Creates a time picker component

    ###### Parameters

    - `minutes`: minutes since midnight as a time of day

    ###### Returns

    a time version of the picker component

  - ### createDurationMinutes

    public static PickerComponent createDurationMinutes(int ms)

    Creates a duration minutes picker component

    ###### Parameters

    - `ms`: the duration value in milliseconds

    ###### Returns

    a duration version of the picker component

  - ### createDurationHoursMinutes

    public static PickerComponent createDurationHoursMinutes(int hours, int minutes)

    Creates a duration hours + minutes picker component

    ###### Parameters

    - `hours`: the number of hours

    - `minutes`: the number of minutes

    ###### Returns

    a duration version of the picker component

  - ### createPickerInstance

    protected Picker createPickerInstance()

    Allows developers to subclass the Picker component instance to customize behaviors of the subclass

    ###### Returns

    the picker instance

  - ### getEditor

    public final Component getEditor()

    Returns the editor component e.g. text field picker etc.

    ###### Returns

    the editor component

    Specified by:
      `getEditor` in class `InputComponent`

  - ### getPicker

    public Picker getPicker()

    Returns the picker instance

    ###### Returns

    the picker

  - ### onTopMode

    public PickerComponent onTopMode(boolean onTopMode)

    Overridden for covariant return type

    Sets the on top mode which places the label above the text when true. It's to the left of the text otherwise (right in bidi languages). This is determined by the platform theme using the `textComponentOnTopBool` theme constant which defaults to false

    ###### Parameters

    - `onTopMode`: true for the label to be above the text

    ###### Returns

    this for chaining calls E.g. `TextComponent tc = new TextComponent().text("Text").label("Label");`

    Overrides:
      `onTopMode` in class `InputComponent`

  - ### errorMessage

    public PickerComponent errorMessage(String errorMessage)

    Overridden for covariant return type

    Sets the text of the error label

    ###### Parameters

    - `errorMessage`: the text

    ###### Returns

    this for chaining calls E.g. `TextComponent tc = new TextComponent().text("Text").label("Label");`

    Overrides:
      `errorMessage` in class `InputComponent`

  - ### label

    public PickerComponent label(String text)

    Overridden for covariant return type

    Sets the text of the label

    ###### Parameters

    - `text`: the text

    ###### Returns

    this for chaining calls E.g. `TextComponent tc = new TextComponent().text("Text").label("Label");`

    }

    Overrides:
      `label` in class `InputComponent`