public class Picker

  1. Object
  2. Component
  3. Label
  4. Button
  5. Picker

ImplementsActionSource<ActionEvent>, Animation, Editable, IconHolder, ReleasableComponent, SelectableIconHolder, StyleListener, TextHolder

Picker is a component and API that allows either popping up a spinner or using the native picker API when applicable. This is quite important for some platforms where the native spinner behavior is very hard to replicate.

Form hi = new Form("Picker", new BoxLayout(BoxLayout.Y_AXIS));
Picker datePicker = new Picker();
datePicker.setType(Display.PICKER_TYPE_DATE);
Picker dateTimePicker = new Picker();
dateTimePicker.setType(Display.PICKER_TYPE_DATE_AND_TIME);
Picker timePicker = new Picker();
timePicker.setType(Display.PICKER_TYPE_TIME);
Picker stringPicker = new Picker();
stringPicker.setType(Display.PICKER_TYPE_STRINGS);

datePicker.setDate(new Date());
dateTimePicker.setDate(new Date());
timePicker.setTime(10 * 60); // 10:00AM = Minutes since midnight
stringPicker.setStrings("A Game of Thrones", "A Clash Of Kings", "A Storm Of Swords", "A Feast For Crows",
        "A Dance With Dragons", "The Winds of Winter", "A Dream of Spring");
stringPicker.setSelectedString("A Game of Thrones");

hi.add(datePicker).add(dateTimePicker).add(timePicker).add(stringPicker);
hi.show();

Nested types

interface Picker.DateGetterFunctional interface that supplies the default Date to display when a date-type picker is opened without an explicit value.
class Picker.LightweightPopupButtonPlacementPlacement options for custom lightweight popup buttons.

Constructors

public Picker()Default constructor

Methods

public void addLightweightPopupButton(String text, Runnable action)Adds a custom button to the lightweight picker popup in the default placement between the Cancel and Done areas.
public void addLightweightPopupButton(String text, Runnable action, int placement)Adds a custom button to the lightweight picker popup with the default Component#LEFT alignment.
public void addLightweightPopupButton(String text, Runnable action, int placement, int alignment)Adds a custom button to the lightweight picker popup at a specific horizontal alignment within its row.
public void clearLightweightPopupButtons()Removes all custom lightweight popup buttons that were previously added with #addLightweightPopupButton.
public List<String> getLightweightPopupButtonLabels()Returns an immutable list of custom button labels currently configured for the lightweight popup.
public static boolean isDefaultUseLightweightPopup()Whether useLightweightPopup should default to true, this can be set via the theme constant lightweightPickerBool
public static void setDefaultUseLightweightPopup(boolean aDefaultUseLightweightPopup)Whether useLightweightPopup should default to true, this can be set via the theme constant lightweightPickerBool
public void setHourRange(int min, int max)Sets the hour range for this picker.
public int getMinHour()Gets the minimum hour to show for time and datetime pickers.
public int getMaxHour()Gets the minimum hour to show for time and datetime pickers.
public Date getStartDate()Gets the start date of the picker.
public void setStartDate(Date start)Sets the start date of the picker.
public Date getEndDate()Gets the end date of the picker.
public void setEndDate(Date end)Sets the end date of the picker.
public boolean isUseLightweightPopup()Checks if this picker is in lightweight mode.
public void setUseLightweightPopup(boolean useLightweightPopup)Sets the picker to use lightweight mode for its widgets.
public void startEditingAsync()If the component #isEditable(), then this will start the editing process.
public void stopEditing(Runnable onFinish)Stops the editing process.
public boolean isEditing()Checks if the component is currently being edited.
public boolean isEditable()Checks to see if the component is editable.
public int getType()Returns the type of the picker
public void setType(int type)Sets the type of the picker to one of Display.PICKER_TYPE_DATE, Display.PICKER_TYPE_DATE_AND_TIME, Display.PICKER_TYPE_STRINGS, Display.PICKER_TYPE_DURATION, Display.PICKER_TYPE_DURATION_HOURS, Display.PICKER_TYPE_DURATION_MINUTES or Displa…
public Date getDate()Returns the date, this value is used both for type date/date and time.
public void setDate(Date d)Sets the date, this value is used both for type date/date and time.
public void setDefaultDate(Picker.DateGetter getter)Installs a dynamic default for PICKER_TYPE_DATE, PICKER_TYPE_DATE_AND_TIME, and PICKER_TYPE_CALENDAR pickers.
public void setDefaultDate(Date d)Convenience overload that pins the picker’s default to a fixed date.
public Picker.DateGetter getDefaultDate()Returns the DateGetter previously installed via setDefaultDate(DateGetter) (or the wrapper produced by the Date overload), or null if no default has been configured.
public String[] getStrings()Returns the String array matching the metadata
public void setStrings(String... strs)Sets the string entries for the string picker.
public String getSelectedString()Returns the current string.
public void setSelectedString(String str)Sets the current value in a string array picker.
public int getSelectedStringIndex()Returns the index of the selected string.
public void setSelectedStringIndex(int index)Sets the index of the selected string.
protected void updateValue()Updates the display value of the picker, subclasses can override this to invoke set text with the right value
public void setTime(int hour, int minute)Convenience method equivalent to invoking setTime(hour * 60 + minute);
public int getTime()This value is only used for time type and is ignored in the case of date and time where both are embedded within the date.
public void setTime(int time)This value is only used for time type and is ignored in the case of date and time where both are embedded within the date.
public void setMinuteStep(int step)Sets the minute step size for PICKER_TYPE_DURATION, and PICKER_TYPE_DURATION_TIME types.
public void setDuration(int hour, int minute)Convenience method for setting duration in hours and minutes.
public long getDuration()This value is used for the duration type.
public void setDuration(long duration)This value is only used for duration type.
public int getDurationHours()Gets the duration hours.
public int getDurationMinutes()Gets the duration minutes.
public boolean isShowMeridiem()Indicates whether hours should be rendered as AM/PM or 24hr format
public void setShowMeridiem(boolean showMeridiem)Indicates whether hours should be rendered as AM/PM or 24hr format
public Object getRenderingPrototype()When using a lightweight spinner this will be used as the rendering prototype
public void setRenderingPrototype(Object renderingPrototype)When using a lightweight spinner this will be used as the rendering prototype
public SimpleDateFormat getFormatter()Allows us to define a date format for the display of dates/times
public void setFormatter(SimpleDateFormat formatter)Allows us to define a date format for the display of dates/times
public int getPreferredPopupWidth()The preferred width of the popup dialog.
public void setPreferredPopupWidth(int width)The preferred width of the popup dialog for the picker.
public int getPreferredPopupHeight()The preferred height of the popup dialog.
public void setPreferredPopupHeight(int height)The preferred height of the popup dialog for the picker.
public String[] getPropertyNames()A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code
public Class[] getPropertyTypes()Matches the property names method (see that method for further details).
public String[] getPropertyTypeNames()This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],I…
public Object getPropertyValue(String name)Returns the current value of the property name, this method is used by the GUI builder
public String setPropertyValue(String name, Object value)Sets a new value to the given property, returns an error message if failed and null if successful.
public Object getValue()Returns the value which works for all picker types
public void paint(Graphics g)This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API’s to let the PLAF perform the rendering.
public Style getStyle()Returns the current Component Style allowing code to draw the current component, you should normally use getUnselected/Pressed/DisabledStyle() and not this method since it will return different values based on component state.

Inherited fields

Inherited methods

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getUIManager, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, clearClientProperties, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, 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, getScrollable, paintBackground, isScrollable, isScrollableX, isScrollableY, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, getBottomGap, getSideGap, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, stopScrollMomentum, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, 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, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getPressedStyle, setPressedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, deinitialize, initComponent, isInitialized, setInitialized, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, 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, cancelRepaints, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

Picker

public Picker()
Default constructor

Method details

addLightweightPopupButton

public void addLightweightPopupButton(String text, Runnable action)
Adds a custom button to the lightweight picker popup in the default placement between the Cancel and Done areas.

Parameters

text String
Button label.
action Runnable
Action to run when the button is pressed.

addLightweightPopupButton

public void addLightweightPopupButton(String text, Runnable action, int placement)
Adds a custom button to the lightweight picker popup with the default Component#LEFT alignment.

Parameters

text String
Button label.
action Runnable
Action to run when the button is pressed.
placement int
One of LightweightPopupButtonPlacement#BETWEEN_CANCEL_AND_DONE, LightweightPopupButtonPlacement#ABOVE_SPINNER, or LightweightPopupButtonPlacement#BELOW_SPINNER.

addLightweightPopupButton

public void addLightweightPopupButton(String text, Runnable action, int placement, int alignment)
Adds a custom button to the lightweight picker popup at a specific horizontal alignment within its row. Buttons that share the same placement and alignment are packed in declaration order; mixing alignments lets you put some buttons on the left and others on the right of the same row.

Parameters

text String
Button label.
action Runnable
Action to run when the button is pressed.
placement int
One of LightweightPopupButtonPlacement#BETWEEN_CANCEL_AND_DONE, LightweightPopupButtonPlacement#ABOVE_SPINNER, or LightweightPopupButtonPlacement#BELOW_SPINNER.
alignment int
One of Component#LEFT, Component#CENTER, or Component#RIGHT.

clearLightweightPopupButtons

public void clearLightweightPopupButtons()
Removes all custom lightweight popup buttons that were previously added with #addLightweightPopupButton.

getLightweightPopupButtonLabels

public List<String> getLightweightPopupButtonLabels()
Returns an immutable list of custom button labels currently configured for the lightweight popup.

isDefaultUseLightweightPopup

public static boolean isDefaultUseLightweightPopup()
Whether useLightweightPopup should default to true, this can be set via the theme constant lightweightPickerBool

Returns

the defaultUseLightweightPopup

setDefaultUseLightweightPopup

public static void setDefaultUseLightweightPopup(boolean aDefaultUseLightweightPopup)
Whether useLightweightPopup should default to true, this can be set via the theme constant lightweightPickerBool

Parameters

aDefaultUseLightweightPopup boolean
the defaultUseLightweightPopup to set

setHourRange

public void setHourRange(int min, int max)
Sets the hour range for this picker. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

Parameters

min int
The minimum hour to display (0-24) or -1 for no limit.
max int
The maximum hour to display (0-24) or -1 for no limit

getMinHour

public int getMinHour()
Gets the minimum hour to show for time and datetime pickers. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

Returns

The minimum hour. 0-24, or -1 for no limit.

getMaxHour

public int getMaxHour()
Gets the minimum hour to show for time and datetime pickers. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

Returns

The minimum hour. 0-24, or -1 for no limit.

getStartDate

public Date getStartDate()
Gets the start date of the picker. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_DATE. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

Returns

The start date or null if there is none set.

This does not apply to the time. Only the date. You can set the hour range using int).

setStartDate

public void setStartDate(Date start)

Sets the start date of the picker. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_DATE. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

This does not affect the time. Only the date. You can set the hour range using int).

Parameters

start Date
The start date.

getEndDate

public Date getEndDate()
Gets the end date of the picker. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_DATE. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

Returns

The end date or null if there is none set.

This does not apply to the time. Only the date. You can set the hour range using int).

setEndDate

public void setEndDate(Date end)

Sets the end date of the picker. Only applicable for types Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_DATE. Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.

This does not affect the time. Only the date. You can set the hour range using int).

Parameters

end Date
The end date.

isUseLightweightPopup

public boolean isUseLightweightPopup()
Checks if this picker is in lightweight mode. If this returns true, then the picker will use cross-platform lightweight widgets instead of native widgets.

setUseLightweightPopup

public void setUseLightweightPopup(boolean useLightweightPopup)
Sets the picker to use lightweight mode for its widgets. With this mode enabled the picker will use cross-platform lightweight widgets instead of native widgets.

startEditingAsync

public void startEditingAsync()
If the component #isEditable(), then this will start the editing process. For TextFields, this results in showing the keyboard and allowing the user to edit the input. For the Picker, this will display the popup.

stopEditing

public void stopEditing(Runnable onFinish)
Stops the editing process.

Parameters

onFinish Runnable
Callback called when the editing is complete.

isEditing

public boolean isEditing()
Checks if the component is currently being edited.

Returns

True if the component is currently being edited.

isEditable

public boolean isEditable()
Checks to see if the component is editable. This is used for next/previous focus traversal on forms.

getType

public int getType()
Returns the type of the picker

Returns

one of Display.PICKER_TYPE_DATE, Display.PICKER_TYPE_DATE_AND_TIME, Display.PICKER_TYPE_STRINGS, Display.PICKER_TYPE_DURATION, Display.PICKER_TYPE_DURATION_HOURS, Display.PICKER_TYPE_DURATION_MINUTES, or Display.PICKER_TYPE_TIME

setType

public void setType(int type)
Sets the type of the picker to one of Display.PICKER_TYPE_DATE, Display.PICKER_TYPE_DATE_AND_TIME, Display.PICKER_TYPE_STRINGS, Display.PICKER_TYPE_DURATION, Display.PICKER_TYPE_DURATION_HOURS, Display.PICKER_TYPE_DURATION_MINUTES or Display.PICKER_TYPE_TIME

Parameters

type int
the type

getDate

public Date getDate()

Returns the date, this value is used both for type date/date and time. Notice that this value isn’t used for time.

While the lightweight popup is on screen this returns the value visible on the scroll wheels (which only becomes the committed value once the user presses Done), so a custom popup button can read it to compute a relative date. The native picker does not expose the in-progress wheel state, so while a native picker is on screen this still returns the last committed value.

Returns

the date object

setDate

public void setDate(Date d)

Sets the date, this value is used both for type date/date and time. Notice that this value isn’t used for time.

If the lightweight popup is currently on screen the visible scroll wheels are also moved to the new value, so a custom popup button can do setDate(getDate() + n) and have the wheels reflect it (see #addLightweightPopupButton(String, Runnable)). Such changes are staged: if the user dismisses the popup with Cancel the picker rolls back to the date it held before the popup was shown; if the user presses Done the staged value is committed. The native picker is read-only while shown - calling setDate against a Picker whose native popup is open updates the committed value but leaves the on-screen wheels unchanged until the user dismisses and re-opens the picker.

Passing null explicitly clears the picker’s value: subsequent getDate() calls return null (the picker text falls back to the ... placeholder) until either setDate(non-null) is called or the user opens the popup and commits a selection. A configured setDefaultDate getter still seeds the popup wheels on the next open so the user has a sensible starting point, but it no longer leaks into getDate() as an unselected value. Issue #5024.

Parameters

d Date
the new date, or null to clear the picker

setDefaultDate

public void setDefaultDate(Picker.DateGetter getter)
Installs a dynamic default for PICKER_TYPE_DATE, PICKER_TYPE_DATE_AND_TIME, and PICKER_TYPE_CALENDAR pickers. The getter is consulted every time the picker is opened or getDate() is called against a picker whose date has not been pinned by setDate(Date), so dependent defaults (e.g. a reminder that should fire one hour before a separately-tracked due date) stay in sync with the value they depend on. Passing null removes the default and reverts to new Date().

Parameters

getter Picker.DateGetter
the supplier of the default date, or null to restore the framework default of new Date()

setDefaultDate

public void setDefaultDate(Date d)
Convenience overload that pins the picker’s default to a fixed date. Equivalent to passing a DateGetter that always returns d. Passing null clears the default.

Parameters

d Date
the fixed default date, or null to restore the framework default

getDefaultDate

public Picker.DateGetter getDefaultDate()
Returns the DateGetter previously installed via setDefaultDate(DateGetter) (or the wrapper produced by the Date overload), or null if no default has been configured.

getStrings

public String[] getStrings()
Returns the String array matching the metadata

Returns

a string array

setStrings

public void setStrings(String... strs)

Sets the string entries for the string picker.

sample usage for this method below:

Toolbar.setGlobalToolbar(true);
Form hi = new Form("Transitions", new BoxLayout(BoxLayout.Y_AXIS));
Style bg = hi.getContentPane().getUnselectedStyle();
bg.setBgTransparency(255);
bg.setBgColor(0xff0000);
Button showTransition = new Button("Show");
Picker pick = new Picker();
pick.setStrings("Slide", "SlideFade", "Cover", "Uncover", "Fade", "Flip");
pick.setSelectedString("Slide");
TextField duration = new TextField("10000", "Duration", 6, TextArea.NUMERIC);
CheckBox horizontal = CheckBox.createToggle("Horizontal");
pick.addActionListener((e) -> {
    String s = pick.getSelectedString().toLowerCase();
    horizontal.setEnabled(s.equals("slide") || s.indexOf("cover") > -1);
});
horizontal.setSelected(true);
hi.add(showTransition).
    add(pick).
    add(duration).
    add(horizontal);

Form dest = new Form("Destination");
bg = dest.getContentPane().getUnselectedStyle();
bg.setBgTransparency(255);
bg.setBgColor(0xff);
dest.setBackCommand(
        dest.getToolbar().addCommandToLeftBar("Back", null, (e) -> hi.showBack()));

showTransition.addActionListener((e) -> {
    int h = CommonTransitions.SLIDE_HORIZONTAL;
    if(!horizontal.isSelected()) {
        h = CommonTransitions.SLIDE_VERTICAL;
    }
    switch(pick.getSelectedString()) {
        case "Slide":
            hi.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(CommonTransitions.createSlide(h, true, duration.getAsInt(3000)));
            break;
        case "SlideFade":
            hi.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(CommonTransitions.createSlideFadeTitle(true, duration.getAsInt(3000)));
            break;
        case "Cover":
            hi.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(CommonTransitions.createCover(h, true, duration.getAsInt(3000)));
            break;
        case "Uncover":
            hi.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(CommonTransitions.createUncover(h, true, duration.getAsInt(3000)));
            break;
        case "Fade":
            hi.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(CommonTransitions.createFade(duration.getAsInt(3000)));
            break;
        case "Flip":
            hi.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
            dest.setTransitionOutAnimator(new FlipTransition(-1, duration.getAsInt(3000)));
            break;
    }
    dest.show();
});
hi.show();

Parameters

strs String...
string array

getSelectedString

public String getSelectedString()
Returns the current string. While the lightweight popup is on screen this returns the value visible on the scroll wheel; the native picker does not expose its in-progress wheel state, so while a native picker is on screen this still returns the last committed value.

Returns

the selected string

setSelectedString

public void setSelectedString(String str)
Sets the current value in a string array picker. If the lightweight popup is on screen the visible scroll wheel is also moved to the new value, and the change is staged: a Cancel press rolls back to the value the picker held before the popup was shown, while a Done press commits it. The native picker is read-only while shown so against a native popup this updates only the committed value.

Parameters

str String
the current value

getSelectedStringIndex

public int getSelectedStringIndex()
Returns the index of the selected string. While the lightweight popup is on screen this returns the index visible on the scroll wheel; the native picker still returns the last committed index.

Returns

the selected string offset or -1

setSelectedStringIndex

public void setSelectedStringIndex(int index)
Sets the index of the selected string. If the lightweight popup is on screen the visible wheel is also moved to the new value, and the change is staged: a Cancel press rolls back to the value the picker held before the popup was shown, while a Done press commits it. The native picker is read-only while shown so against a native popup this updates only the committed value.

Parameters

index int
sets the index of the selected string

updateValue

protected void updateValue()
Updates the display value of the picker, subclasses can override this to invoke set text with the right value

setTime

public void setTime(int hour, int minute)
Convenience method equivalent to invoking setTime(hour * 60 + minute);

Parameters

hour int
the hour in 24hr format
minute int
the minute within the hour

getTime

public int getTime()
This value is only used for time type and is ignored in the case of date and time where both are embedded within the date. While the lightweight popup is on screen this returns the value visible on the scroll wheels; the native picker still returns the last committed value.

Returns

the time value as minutes since midnight e.g. 630 is 10:30am

setTime

public void setTime(int time)
This value is only used for time type and is ignored in the case of date and time where both are embedded within the date. If the lightweight popup is on screen the visible scroll wheels are also moved to the new value, and the change is staged: a Cancel press rolls back to the value the picker held before the popup was shown, while a Done press commits it. The native picker is read-only while shown so against a native popup this updates only the committed value.

Parameters

time int
the time value as minutes since midnight e.g. 630 is 10:30am

setMinuteStep

public void setMinuteStep(int step)
Sets the minute step size for PICKER_TYPE_DURATION, and PICKER_TYPE_DURATION_TIME types.

Parameters

step int
The step size in minutes.

setDuration

public void setDuration(int hour, int minute)
Convenience method for setting duration in hours and minutes.

Parameters

hour int
The hours for duration.
minute int
The minutes for duration.

getDuration

public long getDuration()
This value is used for the duration type. While the lightweight popup is on screen this returns the value visible on the scroll wheels; the native picker still returns the last committed value.

Returns

The duration in milliseconds.

setDuration

public void setDuration(long duration)
This value is only used for duration type. If the lightweight popup is on screen the visible scroll wheels are also moved to the new value, and the change is staged: a Cancel press rolls back to the value the picker held before the popup was shown, while a Done press commits it. The native picker is read-only while shown so against a native popup this updates only the committed value.

Parameters

duration long
The duration value in milliseconds.

getDurationHours

public int getDurationHours()
Gets the duration hours. Used only for duration type.

Returns

The duration hours.

getDurationMinutes

public int getDurationMinutes()
Gets the duration minutes. Used only for duration type.

Returns

The duration minutes.

isShowMeridiem

public boolean isShowMeridiem()
Indicates whether hours should be rendered as AM/PM or 24hr format

Returns

the showMeridiem

setShowMeridiem

public void setShowMeridiem(boolean showMeridiem)
Indicates whether hours should be rendered as AM/PM or 24hr format

Parameters

showMeridiem boolean
the showMeridiem to set

getRenderingPrototype

public Object getRenderingPrototype()
When using a lightweight spinner this will be used as the rendering prototype

Returns

the renderingPrototype

setRenderingPrototype

public void setRenderingPrototype(Object renderingPrototype)
When using a lightweight spinner this will be used as the rendering prototype

Parameters

renderingPrototype Object
the renderingPrototype to set

getFormatter

public SimpleDateFormat getFormatter()
Allows us to define a date format for the display of dates/times

Returns

the defined formatter

setFormatter

public void setFormatter(SimpleDateFormat formatter)
Allows us to define a date format for the display of dates/times

Parameters

formatter SimpleDateFormat
the new formatter

getPreferredPopupWidth

public int getPreferredPopupWidth()
The preferred width of the popup dialog. This will only be used on devices where the popup width and height are configurable, such as the iPad or tablets. On iPhone, the picker always spans the width of the screen along the bottom.

setPreferredPopupWidth

public void setPreferredPopupWidth(int width)
The preferred width of the popup dialog for the picker. This will only be used on devices where the popup width and height are configurable, such as the iPad or tablets. On iPhone, the picker always spans the width of the screen along the bottom.

Parameters

width int
The preferred width of the popup.

getPreferredPopupHeight

public int getPreferredPopupHeight()
The preferred height of the popup dialog. This will only be used on devices where the popup width and height are configurable, such as the iPad or tablets. On iPhone, the picker always spans the width of the screen along the bottom.

setPreferredPopupHeight

public void setPreferredPopupHeight(int height)
The preferred height of the popup dialog for the picker. This will only be used on devices where the popup width and height are configurable, such as the iPad or tablets. On iPhone, the picker always spans the width of the screen along the bottom.

Parameters

height int
The preferred height of the popup.

getPropertyNames

public String[] getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

Returns

the property names allowing mutation

getPropertyTypes

public Class[] getPropertyTypes()
Matches the property names method (see that method for further details).

Returns

the types of the properties

getPropertyTypeNames

public String[] getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer

Returns

Array of type names

getPropertyValue

public Object getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder

Parameters

name String
the name of the property

Returns

the value of said property

setPropertyValue

public String setPropertyValue(String name, Object value)
Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as “$designMode” might be sent to components to indicate application state.

Parameters

name String
the name of the property
value Object
new value for the property

Returns

error message or null

getValue

public Object getValue()
Returns the value which works for all picker types

Returns

the value object

paint

public void paint(Graphics g)
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API’s to let the PLAF perform the rendering.

Parameters

g Graphics
the component graphics

getStyle

public Style getStyle()
Returns the current Component Style allowing code to draw the current component, you should normally use getUnselected/Pressed/DisabledStyle() and not this method since it will return different values based on component state.

Returns

the component Style object