public class 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.DateGetter | Functional interface that supplies the default Date to display when a date-type picker is opened without an explicit value. |
class Picker.LightweightPopupButtonPlacement | Placement 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
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Button
isCapsTextDefault, setCapsTextDefault, isButtonRippleEffectDefault, setButtonRippleEffectDefault, bindStateTo, unbindStateFrom, resetFocusable, getState, setReleased, getPressedIcon, setPressedIcon, getRolloverPressedIcon, setRolloverPressedIcon, getDisabledIcon, setDisabledIcon, getRolloverIcon, setRolloverIcon, addStateChangeListener, removeStateChangeListener, addActionListener, removeActionListener, getActionListeners, getListeners, getIconFromState, fireActionEvent, pressed, released, released, keyPressed, keyReleased, keyRepeated, fireClicked, isSelectableInteraction, pointerHover, pointerHoverReleased, pointerPressed, pointerReleased, dragInitiated, calcPreferredSize, getBorder, getCommand, setCommand, isSelected, setAlignment, isToggle, setToggle, setUIID, animate, isOppositeSide, getReleaseRadius, setReleaseRadius, isAutoRelease, setAutoRelease, isCapsText, setCapsText, setText
From Label
getDefaultGap, setDefaultGap, isDefaultTickerEnabled, setDefaultTickerEnabled, laidOut, getBadgeText, setBadgeText, setBadgeUIID, getBadgeStyleComponent, getIconStyleComponent, setFontIcon, setMaterialIcon, setFontIcon, getMaterialIcon, setMaterialIcon, getFontIcon, setFontIcon, getMaterialIconSize, getFontIconSize, getIconFont, getBaselineResizeBehavior, getBaseline, refreshTheme, initLaf, getText, getIcon, setIcon, getVerticalAlignment, setVerticalAlignment, getAlignment, getTextPosition, setTextPosition, getGap, setGap, paramString, getMaxAutoSize, setMaxAutoSize, getMinAutoSize, setMinAutoSize, getShiftText, setShiftText, shouldTickerStart, startTicker, startTicker, stopTicker, isTickerRunning, isTickerEnabled, setTickerEnabled, isEndsWith3Points, setEndsWith3Points, getMask, setMask, getMaskName, setMaskName, getMaskedIcon, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, isShouldLocalize, setShouldLocalize, getShiftMillimeters, setShiftMillimeters, setShiftMillimeters, getShiftMillimetersF, isShowEvenIfBlank, setShowEvenIfBlank, getStringWidth, isLegacyRenderer, setLegacyRenderer, styleChanged, initUnselectedStyle, isAutoSizeMode, setAutoSizeMode, isTextSelectionEnabled, setTextSelectionEnabled, getTextSelectionSupport, getIconUIID, setIconUIID
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()Method details
addLightweightPopupButton
public void addLightweightPopupButton(String text, Runnable action)Cancel and Done areas.Parameters
textString- Button label.
actionRunnable- Action to run when the button is pressed.
addLightweightPopupButton
public void addLightweightPopupButton(String text, Runnable action, int placement)Component#LEFT alignment.Parameters
textString- Button label.
actionRunnable- Action to run when the button is pressed.
placementint- One of
LightweightPopupButtonPlacement#BETWEEN_CANCEL_AND_DONE,LightweightPopupButtonPlacement#ABOVE_SPINNER, orLightweightPopupButtonPlacement#BELOW_SPINNER.
addLightweightPopupButton
public void addLightweightPopupButton(String text, Runnable action, int placement, int alignment)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
textString- Button label.
actionRunnable- Action to run when the button is pressed.
placementint- One of
LightweightPopupButtonPlacement#BETWEEN_CANCEL_AND_DONE,LightweightPopupButtonPlacement#ABOVE_SPINNER, orLightweightPopupButtonPlacement#BELOW_SPINNER. alignmentint- One of
Component#LEFT,Component#CENTER, orComponent#RIGHT.
clearLightweightPopupButtons
public void clearLightweightPopupButtons()#addLightweightPopupButton.getLightweightPopupButtonLabels
public List<String> getLightweightPopupButtonLabels()isDefaultUseLightweightPopup
public static boolean isDefaultUseLightweightPopup()lightweightPickerBoolReturns
setDefaultUseLightweightPopup
public static void setDefaultUseLightweightPopup(boolean aDefaultUseLightweightPopup)lightweightPickerBoolParameters
aDefaultUseLightweightPopupboolean- the defaultUseLightweightPopup to set
setHourRange
public void setHourRange(int min, int max)Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME.
Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.Parameters
minint- The minimum hour to display (0-24) or -1 for no limit.
maxint- The maximum hour to display (0-24) or -1 for no limit
See also
getMinHour
public int getMinHour()Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME.
Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.Returns
getMaxHour
public int getMaxHour()Display#PICKER_TYPE_DATE_AND_TIME and Display#PICKER_TYPE_TIME.
Also, only applicable to lightweight picker (i.e. #isUseLightweightPopup() == true.Returns
getStartDate
public Date getStartDate()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
startDate- The start date.
getEndDate
public Date getEndDate()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
endDate- The end date.
isUseLightweightPopup
public boolean isUseLightweightPopup()setUseLightweightPopup
public void setUseLightweightPopup(boolean useLightweightPopup)startEditingAsync
public void startEditingAsync()#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)Parameters
onFinishRunnable- Callback called when the editing is complete.
isEditing
public boolean isEditing()Returns
isEditable
public boolean isEditable()getType
public int getType()Returns
setType
public void setType(int type)Parameters
typeint- 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
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
dDate- the new date, or
nullto clear the picker
setDefaultDate
public void setDefaultDate(Picker.DateGetter getter)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
getterPicker.DateGetter- the supplier of the default date, or
nullto restore the framework default ofnew Date()
setDefaultDate
public void setDefaultDate(Date d)DateGetter that always returns d. Passing
null clears the default.Parameters
dDate- the fixed default date, or
nullto restore the framework default
getDefaultDate
public Picker.DateGetter getDefaultDate()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
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
strsString...- string array
getSelectedString
public String getSelectedString()Returns
setSelectedString
public void setSelectedString(String str)Parameters
strString- the current value
getSelectedStringIndex
public int getSelectedStringIndex()Returns
setSelectedStringIndex
public void setSelectedStringIndex(int index)Parameters
indexint- sets the index of the selected string
updateValue
protected void updateValue()setTime
public void setTime(int hour, int minute)Parameters
hourint- the hour in 24hr format
minuteint- the minute within the hour
getTime
public int getTime()Returns
setTime
public void setTime(int time)Parameters
timeint- the time value as minutes since midnight e.g. 630 is 10:30am
setMinuteStep
public void setMinuteStep(int step)Parameters
stepint- The step size in minutes.
setDuration
public void setDuration(int hour, int minute)Parameters
hourint- The hours for duration.
minuteint- The minutes for duration.
getDuration
public long getDuration()Returns
setDuration
public void setDuration(long duration)Parameters
durationlong- The duration value in milliseconds.
getDurationHours
public int getDurationHours()Returns
getDurationMinutes
public int getDurationMinutes()Returns
isShowMeridiem
public boolean isShowMeridiem()Returns
setShowMeridiem
public void setShowMeridiem(boolean showMeridiem)Parameters
showMeridiemboolean- the showMeridiem to set
getRenderingPrototype
public Object getRenderingPrototype()Returns
setRenderingPrototype
public void setRenderingPrototype(Object renderingPrototype)Parameters
renderingPrototypeObject- the renderingPrototype to set
getFormatter
public SimpleDateFormat getFormatter()Returns
setFormatter
public void setFormatter(SimpleDateFormat formatter)Parameters
formatterSimpleDateFormat- the new formatter
getPreferredPopupWidth
public int getPreferredPopupWidth()setPreferredPopupWidth
public void setPreferredPopupWidth(int width)Parameters
widthint- The preferred width of the popup.
getPreferredPopupHeight
public int getPreferredPopupHeight()setPreferredPopupHeight
public void setPreferredPopupHeight(int height)Parameters
heightint- The preferred height of the popup.
getPropertyNames
public String[] getPropertyNames()Returns
getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyTypeNames
public String[] getPropertyTypeNames()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property
Returns
getValue
public Object getValue()Returns
paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
getStyle
public Style getStyle()