public class Picker extends Button
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.
STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER
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 and Description |
---|
Picker()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
Date |
getDate()
Returns the date, this value is used both for type date/date and time.
|
long |
getDuration()
This value is used for the duration type.
|
int |
getDurationHours()
Gets the duration hours.
|
int |
getDurationMinutes()
Gets the duration minutes.
|
Date |
getEndDate()
Gets the end date of the picker.
|
SimpleDateFormat |
getFormatter()
Allows us to define a date format for the display of dates/times
|
int |
getMaxHour()
Gets the minimum hour to show for time and datetime pickers.
|
int |
getMinHour()
Gets the minimum hour to show for time and datetime pickers.
|
int |
getPreferredPopupHeight()
The preferred height of the popup dialog.
|
int |
getPreferredPopupWidth()
The preferred width of the popup dialog.
|
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
|
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
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
Object |
getRenderingPrototype()
When using a lightweight spinner this will be used as the rendering prototype
|
String |
getSelectedString()
Returns the current string
|
int |
getSelectedStringIndex()
Returns the index of the selected string
|
Date |
getStartDate()
Gets the start date of the picker.
|
String[] |
getStrings()
Returns the String array matching the metadata
|
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.
|
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.
|
int |
getType()
Returns the type of the picker
|
Object |
getValue()
Returns the value which works for all picker types
|
static boolean |
isDefaultUseLightweightPopup()
Whether useLightweightPopup should default to true, this can be set via
the theme constant
lightweightPickerBool |
boolean |
isEditable()
Checks to see if the component is editable.
|
boolean |
isEditing()
Checks if the component is currently being edited.
|
boolean |
isShowMeridiem()
Indicates whether hours should be rendered as AM/PM or 24hr format
|
boolean |
isUseLightweightPopup()
Checks if this picker is in lightweight mode.
|
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.
|
void |
setDate(Date d)
Sets the date, this value is used both for type date/date and time.
|
static void |
setDefaultUseLightweightPopup(boolean aDefaultUseLightweightPopup)
Whether useLightweightPopup should default to true, this can be set via
the theme constant
lightweightPickerBool |
void |
setDuration(int hour,
int minute)
Convenience method for setting duration in hours and minutes.
|
void |
setDuration(long duration)
This value is only used for duration type.
|
void |
setEndDate(Date end)
Sets the end date of the picker.
|
void |
setFormatter(SimpleDateFormat formatter)
Allows us to define a date format for the display of dates/times
|
void |
setHourRange(int min,
int max)
Sets the hour range for this picker.
|
void |
setMinuteStep(int step)
Sets the minute step size for PICKER_TYPE_DURATION, and PICKER_TYPE_DURATION_TIME types.
|
void |
setPreferredPopupHeight(int height)
The preferred height of the popup dialog for the picker.
|
void |
setPreferredPopupWidth(int width)
The preferred width of the popup dialog for the picker.
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setRenderingPrototype(Object renderingPrototype)
When using a lightweight spinner this will be used as the rendering prototype
|
void |
setSelectedString(String str)
Sets the current value in a string array picker
|
void |
setSelectedStringIndex(int index)
Returns the index of the selected string
|
void |
setShowMeridiem(boolean showMeridiem)
Indicates whether hours should be rendered as AM/PM or 24hr format
|
void |
setStartDate(Date start)
Sets the start date of the picker.
|
void |
setStrings(String... strs)
Sets the string entries for the string picker.
|
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.
|
void |
setTime(int hour,
int minute)
Convenience method equivalent to invoking setTime(hour * 60 + minute);
|
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
|
void |
setUseLightweightPopup(boolean useLightweightPopup)
Sets the picker to use lightweight mode for its widgets.
|
void |
startEditingAsync()
If the component
Component.isEditable() , then this will start the editing
process. |
void |
stopEditing(Runnable onFinish)
Stops the editing process.
|
protected void |
updateValue()
Updates the display value of the picker, subclasses can override this to invoke
set text with the right value
|
addActionListener, addStateChangeListener, animate, bindStateTo, calcPreferredSize, dragInitiated, fireActionEvent, fireClicked, getActionListeners, getBorder, getCommand, getDisabledIcon, getIconFromState, getListeners, getPressedIcon, getReleaseRadius, getRolloverIcon, getRolloverPressedIcon, getState, isAutoRelease, isButtonRippleEffectDefault, isCapsText, isCapsTextDefault, isOppositeSide, isSelectableInteraction, isSelected, isToggle, keyPressed, keyReleased, keyRepeated, pointerHover, pointerHoverReleased, pointerPressed, pointerReleased, pressed, released, released, removeActionListener, removeStateChangeListener, resetFocusable, setAlignment, setAutoRelease, setButtonRippleEffectDefault, setCapsText, setCapsTextDefault, setCommand, setDisabledIcon, setPressedIcon, setReleased, setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setText, setToggle, setUIID, unbindStateFrom
bindProperty, getAlignment, getBadgeStyleComponent, getBadgeText, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getDefaultGap, getFontIcon, getFontIconSize, getGap, getIcon, getIconFont, getIconStyleComponent, getIconUIID, getMask, getMaskedIcon, getMaskName, getMaterialIcon, getMaterialIconSize, getMaxAutoSize, getMinAutoSize, getShiftMillimeters, getShiftMillimetersF, getShiftText, getStringWidth, getText, getTextPosition, getTextSelectionSupport, getVerticalAlignment, initLaf, initUnselectedStyle, isAutoSizeMode, isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank, isTextSelectionEnabled, isTickerEnabled, isTickerRunning, laidOut, paramString, refreshTheme, setAutoSizeMode, setBadgeText, setBadgeUIID, setBoundPropertyValue, setDefaultGap, setDefaultTickerEnabled, setEndsWith3Points, setFontIcon, setFontIcon, setFontIcon, setGap, setIcon, setIconUIID, setLegacyRenderer, setMask, setMaskName, setMaterialIcon, setMaterialIcon, setMaxAutoSize, setMinAutoSize, setShiftMillimeters, setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank, setTextPosition, setTextSelectionEnabled, setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker, styleChanged, unbindProperty
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, 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, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, 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, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, stripMarginAndPadding, toImage, toString, updateNativeOverlay, visibleBoundsContains
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getGap, getIcon, getIconStyleComponent, getIconUIID, getTextPosition, setFontIcon, setGap, setIcon, setIconUIID, setMaterialIcon, setTextPosition
public static boolean isDefaultUseLightweightPopup()
lightweightPickerBool
public static void setDefaultUseLightweightPopup(boolean aDefaultUseLightweightPopup)
lightweightPickerBool
aDefaultUseLightweightPopup
- the defaultUseLightweightPopup to setpublic void setHourRange(int min, int max)
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.PICKER_TYPE_TIME
.
Also, only applicable to lightweight picker (i.e. isUseLightweightPopup()
== true.min
- The minimum hour to display (0-24) or -1 for no limit.max
- The maximum hour to display (0-24) or -1 for no limitgetMinHour()
,
getMaxHour()
public int getMinHour()
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.PICKER_TYPE_TIME
.
Also, only applicable to lightweight picker (i.e. isUseLightweightPopup()
== true.getMaxHour()
,
setHourRange(int, int)
public int getMaxHour()
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.PICKER_TYPE_TIME
.
Also, only applicable to lightweight picker (i.e. isUseLightweightPopup()
== true.getMinHour()
,
setHourRange(int, int)
public void setStartDate(Date start)
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.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 setHourRange(int, int)
.
start
- The start date.getStartDate()
,
setEndDate(java.util.Date)
public void setEndDate(Date end)
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.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 setHourRange(int, int)
.
end
- The end date.setStartDate(java.util.Date)
,
getEndDate()
public Date getStartDate()
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.PICKER_TYPE_DATE
.
Also, only applicable to lightweight picker (i.e. isUseLightweightPopup()
== true.This does not apply to the time. Only the date. You can set the hour range using setHourRange(int, int)
.
getEndDate()
,
setStartDate(java.util.Date)
,
getMinHour()
public Date getEndDate()
CN1Constants.PICKER_TYPE_DATE_AND_TIME
and CN1Constants.PICKER_TYPE_DATE
.
Also, only applicable to lightweight picker (i.e. isUseLightweightPopup()
== true.This does not apply to the time. Only the date. You can set the hour range using setHourRange(int, int)
.
getStartDate()
,
setEndDate(java.util.Date)
,
getMaxHour()
public void setUseLightweightPopup(boolean useLightweightPopup)
useLightweightPopup
- public boolean isUseLightweightPopup()
public void startEditingAsync()
Component
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.startEditingAsync
in interface Editable
startEditingAsync
in class Component
Component.stopEditing(java.lang.Runnable)
,
Component.isEditing()
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public void stopEditing(Runnable onFinish)
Component
stopEditing
in interface Editable
stopEditing
in class Component
onFinish
- Callback called when the editing is complete.Component.startEditingAsync()
,
Component.isEditing()
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public boolean isEditing()
Component
isEditing
in interface Editable
isEditing
in class Component
Component.startEditingAsync()
,
Component.stopEditing(java.lang.Runnable)
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public boolean isEditable()
Component
isEditable
in interface Editable
isEditable
in class Component
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
,
Component.isEditing()
,
Component.startEditingAsync()
,
Component.stopEditing(java.lang.Runnable)
public void setType(int type)
type
- the typepublic int getType()
public Date getDate()
public void setDate(Date d)
d
- the new datepublic void setStrings(String... strs)
Sets the string entries for the string picker.
sample usage for this method below:
strs
- string arraypublic String[] getStrings()
public void setSelectedString(String str)
str
- the current valuepublic String getSelectedString()
public int getSelectedStringIndex()
public void setSelectedStringIndex(int index)
index
- sets the index of the selected stringprotected void updateValue()
public void setTime(int time)
time
- the time value as minutes since midnight e.g. 630 is 10:30ampublic void setTime(int hour, int minute)
hour
- the hour in 24hr formatminute
- the minute within the hourpublic int getTime()
public void setDuration(long duration)
duration
- The duration value in milliseconds.setDuration(int, int)
,
getDuration()
,
getDurationHours()
,
getDurationMinutes()
public void setMinuteStep(int step)
step
- The step size in minutes.public void setDuration(int hour, int minute)
hour
- The hours for duration.minute
- The minutes for duration.setDuration(long)
,
getDuration()
,
getDurationHours()
,
getDurationMinutes()
public long getDuration()
getDurationHours()
,
getDurationMinutes()
public int getDurationHours()
getDurationMinutes()
,
getDuration()
public int getDurationMinutes()
getDurationHours()
,
getDuration()
public boolean isShowMeridiem()
public void setShowMeridiem(boolean showMeridiem)
showMeridiem
- the showMeridiem to setpublic Object getRenderingPrototype()
public void setRenderingPrototype(Object renderingPrototype)
renderingPrototype
- the renderingPrototype to setpublic SimpleDateFormat getFormatter()
public void setFormatter(SimpleDateFormat formatter)
formatter
- the new formatterpublic void setPreferredPopupWidth(int width)
width
- The preferred width of the popup.public void setPreferredPopupHeight(int height)
height
- The preferred height of the popup.public int getPreferredPopupWidth()
public int getPreferredPopupHeight()
public String[] getPropertyNames()
getPropertyNames
in class Label
public Class[] getPropertyTypes()
getPropertyTypes
in class Label
public String[] getPropertyTypeNames()
getPropertyTypeNames
in class Label
public Object getPropertyValue(String name)
getPropertyValue
in class Label
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
setPropertyValue
in class Label
name
- the name of the propertyvalue
- new value for the propertypublic Object getValue()
public void paint(Graphics g)
Label
public Style getStyle()
Component