public class List<T> extends Component implements ActionSource
A set of elements that is rendered using a ListCellRenderer
and are extracted via the ListModel
, notice that
we strongly
discourage usage of lists.
A list can represent many UI concepts ranging from a carousel to a "todo" checklist, this
is made possible thanks to extensive use of Swing's style of MVC. Specifically a list
component is relatively simple, it invokes the model in order to extract the displayed/selected
information and shows it to the user by invoking the cell renderer.
The list class itself is completely decoupled from everything, thus it allows us to extract its content from any source (e.g. network, storage etc.) and display the information in any form (e.g. checkboxed elemenents, icons etc.).
List
is a pretty complex class to use so we generally recommend developers use
Container
,
InfiniteScrollAdapter
or InfiniteContainer
coupled with widgets such as MultiButton
. Arranging those in a
BoxLayout
on the BoxLayout.Y_AXIS
can produce the functionality of the List
with better performance and far simpler code!
Another simpler alternative although not as attractive is the MultiList
class
that removes a lot of the ListCellRenderer
related complexities inherent
in building a list.
The sample below uses the GenericListCellRenderer
class instead of the
DefaultListCellRenderer
. We generally recommend using the builtin classes
as the renderer is probably the greatest source of pitfalls in Lists
.
Container
,
InfiniteContainer
,
InfiniteScrollAdapter
,
MultiButton
,
com.codename1.ui.list
,
MultiList
Modifier and Type | Field and Description |
---|---|
static int |
FIXED_CENTER
Indicates the list selection is fixed into place at the center of the list
|
static int |
FIXED_LEAD
Indicates the list selection is fixed into place at the top of the list
or at the left of the list
|
static int |
FIXED_NONE
Indicates the list isn't fixed and that selection is movable
|
static int |
FIXED_NONE_CYCLIC
Indicates that the list is not fixed in place but cycles its elements
|
static int |
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE
Indicates the list selection will only reach the edge when there are no more
elements in the list.
|
static int |
FIXED_TRAIL
Indicates the list selection is fixed into place at the bottom of the list
or at the right of the list
|
static int |
HORIZONTAL
Indicates the list orientation is HORIZONTAL
|
static int |
VERTICAL
Indicates the list orientation is VERTICAL
|
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 |
---|
List()
Creates a new instance of List with an empty default model
|
List(ListModel model)
Creates a new instance of List with the given model
|
List(T... items)
Creates a new instance of List
|
List(Vector items)
Creates a new instance of List
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Allows binding a listener to user selection actions
|
void |
addItem(T item)
Allows adding an element to a list if the underlying model supports this, notice that
it is an optional operation and if the model does not support it (default list model does)
then this operation may failed.
|
void |
addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events
|
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
protected void |
fireActionEvent()
This method allows us to detect an action event internally without
implementing the action listener interface.
|
protected void |
fireActionEvent(ActionEvent a)
Triggers the event to the listeners
|
protected void |
fireClicked()
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method
in order to allow 3 button devices to work properly.
|
Vector |
getActionListeners()
Deprecated.
use getListeners instead
|
int |
getCurrentSelected()
Returns the visual selection during a drag operation, otherwise equivalent to model.getSelectedIndex
|
protected int |
getDragRegionStatus(int x,
int y)
Indicates if the section within the X/Y area is a "drag region" where
we expect people to drag or press in which case we
can instantly start dragging making perceived performance faster.
|
int |
getFixedSelection()
Indicates whether selection is fixable to place in which case all the
elements in the list move and selection stays in place.
|
protected int |
getGridPosX()
This method should be implemented correctly by subclasses to make snap to grid functionality work
as expected.
|
protected int |
getGridPosY()
This method should be implemented correctly by subclasses to make snap to grid functionality work
as expected.
|
String |
getHint()
Returns the hint text
|
Image |
getHintIcon()
Returns the hint icon
|
int |
getItemGap()
Returns the gap between items
|
Collection |
getListeners()
This method allows extracting the action listeners from the current list
|
int |
getListSizeCalculationSampleCount()
Indicates the number of elements the list should check to determine the element
sizes.
|
int |
getMaxElementHeight()
Maximum number of elements shown in a list, this member is used to calculate
the list preferred size.
|
int |
getMinElementHeight()
Minimum number of elements shown in a list, this member is used to calculate
the list preferred size.
|
ListModel<T> |
getModel()
Returns the model underlying the list
|
int |
getOrientation()
Returns the list orientation
|
ListCellRenderer |
getRenderer()
Returns the renderer which is used to draw list elements
|
T |
getRenderingPrototype()
See set rendering prototype
|
int |
getSelectedIndex()
Returns the current selected offset in the list
|
T |
getSelectedItem()
Returns the current selected item in the list or null for no selection
|
Rectangle |
getSelectedRect()
Returns the component bounds with absolute screen coordinates, for components that include an internal selection behavior
and are not containers (currently only List) this method allows returning the position of the selection
itself which is useful for things such as the popup dialog and similar UI's that need to reference the
position of the selection externally
|
int |
getSideGap()
Returns the gap to be left for the side scrollbar on the Y axis.
|
protected Rectangle |
getVisibleBounds()
Returns the component bounds for scrolling which might differ from the getBounds for large components
e.g.
|
protected void |
initLaf(UIManager uim)
This method initializes the Component defaults constants
|
boolean |
isCommandList()
Indicates that the list should be treated as a list of commands, if the
user "clicks" a command from the list its action performed method is invoked.
|
static boolean |
isDefaultFireOnClick()
Default value for the fire on click behavior
|
static boolean |
isDefaultIgnoreFocusComponentWhenUnfocused()
Indicates whether the list should not paint the focus component if the list
itself has no focus.
|
boolean |
isIgnoreFocusComponentWhenUnfocused()
Indicates whether the list should not paint the focus component if the list
itself has no focus.
|
boolean |
isLongPointerPressActionEnabled()
Enable/disable list action on long pointer press event
|
boolean |
isMutableRendererBackgrounds()
Indicates that the background of a cell renderer might mutate between one entry and the next,
it is recommended that this flag remains false for performance reasons.
|
boolean |
isNumericKeyActions()
Indicate whether pressing the number keys should trigger an action
|
boolean |
isScrollableX()
Indicates whether the component should/could scroll on the X axis
|
boolean |
isScrollableY()
Indicates whether the component should/could scroll on the Y axis
|
protected boolean |
isSelectableInteraction()
This method allows a component to indicate that it is interested in an "implicit" select
command to appear in the "fire" button when 3 softbuttons are defined in a device.
|
protected boolean |
isTactileTouch(int x,
int y)
Elaborate components might not provide tactile feedback for all their areas (e.g.
|
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event
will call this method
|
void |
keyReleased(int keyCode)
If this Component is focused, the key released event
will call this method
|
protected void |
laidOut()
This is a callback method to inform the Component when it's been laidout
on the parent Container
|
protected void |
listSelectionChanged(int oldSelected,
int newSelected)
Callback to allow subclasses to react to a selection change in the model
|
void |
longPointerPress(int x,
int y)
If this Component is focused this method is invoked when the user presses
and holds the pointer on the Component
|
protected void |
modelChanged(int status,
int index)
Callback to allow subclasses to react to a change in the model
|
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.
|
protected String |
paramString()
Returns a string representing the state of this component.
|
void |
pointerDragged(int x,
int y)
If this Component is focused, the pointer dragged event
will call this method
|
void |
pointerHover(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking
the display.
|
void |
pointerHoverReleased(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking
the display.
|
void |
pointerPressed(int x,
int y)
If this Component is focused, the pointer pressed event
will call this method
|
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event
will call this method
|
void |
refreshTheme(boolean merge)
Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
|
void |
removeActionListener(ActionListener l)
Allows binding a listener to user selection actions
|
void |
removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events
|
void |
scrollRectToVisible(Rectangle rect)
Makes sure the selected index is visible if it is not in the current view
rect the list will scroll so it fits within
|
void |
setCommandList(boolean commandList)
Indicates that the list should be treated as a list of commands, if the
user "clicks" a command from the list its action performed method is invoked.
|
static void |
setDefaultFireOnClick(boolean aDefaultFireOnClick)
Default value for the fire on click behavior
|
static void |
setDefaultIgnoreFocusComponentWhenUnfocused(boolean aDefaultIgnoreFocusComponentWhenUnfocused)
Indicates whether the list should not paint the focus component if the list
itself has no focus.
|
void |
setFireOnClick(boolean fireOnClick)
This method determines if the List fires the action event when the pointer
was clicked on one of the items, or only if the item was the selected item
By default the value is true, this setting is only relevant for none fixed
Lists
|
void |
setFixedSelection(int fixedSelection)
Indicates whether selection is fixable to place in which case all the
elements in the list move and selection stays in place.
|
void |
setHandlesInput(boolean b)
Prevents key events from being grabbed for focus traversal.
|
void |
setHint(String hint)
Sets the TextArea hint text, the hint text is displayed on the TextArea
When there is no text in the TextArea
|
void |
setHint(String hint,
Image icon)
Sets the TextArea hint text and Icon, the hint text and icon are
displayed on the TextArea when there is no text in the TextArea
|
void |
setHintIcon(Image icon)
Sets the TextArea hint icon, the hint is displayed on the TextArea
When there is no text in the TextArea
|
void |
setIgnoreFocusComponentWhenUnfocused(boolean ignoreFocusComponentWhenUnfocused)
Indicates whether the list should not paint the focus component if the list
itself has no focus.
|
void |
setInputOnFocus(boolean inputOnFocus)
A list can start handling input implicitly upon gaining focus, this can
make for a more intuitive UI when no other focus elements exist or when
their use case is infrequent.
|
void |
setItemGap(int itemGap)
Set the gap between items
|
void |
setListCellRenderer(ListCellRenderer renderer)
Deprecated.
use setRenderer instead, this method was deprecated to confirm
better to JavaBean convention of having the getter/setter with the same name
|
void |
setListSizeCalculationSampleCount(int listSizeCalculationSampleCount)
Indicates the number of elements the list should check to determine the element
sizes.
|
void |
setLongPointerPressActionEnabled(boolean longPointerPressAction)
Enable/disable list action on long pointer press event
|
void |
setMaxElementHeight(int maxElementHeight)
Maximum number of elements shown in a list, this member is used to calculate
the list preferred size.
|
void |
setMinElementHeight(int minElementHeight)
Minimum number of elements shown in a list, this member is used to calculate
the list preferred size.
|
void |
setModel(ListModel model)
Replaces/sets the model underlying the list
|
void |
setMutableRendererBackgrounds(boolean mutableRendererBackgrounds)
Indicates that the background of a cell renderer might mutate between one entry and the next,
it is recommended that this flag remains false for performance reasons.
|
void |
setNumericKeyActions(boolean numericKeyActions)
Indicate whether pressing the number keys should trigger an action
|
void |
setOrientation(int orientation)
Sets the list orientation HORIZONTAL or VERTICAL
|
void |
setPaintFocusBehindList(boolean paintFocusBehindList)
This method determines if the animated focus is drawn on top of the List
or behind the List when moving.
|
void |
setRenderer(ListCellRenderer renderer)
Sets the renderer which is used to draw list elements
|
void |
setRenderingPrototype(T renderingPrototype)
The rendering prototype is optionally used in calculating the size of the
List and is recommended for performance reasons.
|
void |
setScrollToSelected(boolean scrollToSelected)
This flag indicates to the List if the List should scroll to the selected
element when it's been initialized.
|
void |
setSelectedIndex(int index)
Sets the current selected offset in the list, by default this implementation
will scroll the list to the selection if the selection is outside of the screen
|
void |
setSelectedIndex(int index,
boolean scrollToSelection)
Sets the current selected offset in the list
|
void |
setSelectedItem(T item)
Sets the current selected item in the list
|
void |
setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
Indicates the values within the component have changed and preferred
size should be recalculated
|
protected boolean |
shouldRenderSelection()
Allows subclasses to override the selection rendering for the component, specifically the spinner
in some themes
|
int |
size()
Returns the number of elements in the list, shorthand for
getModel().getSize()
|
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, bindProperty, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, 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, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUIManager, getUnselectedStyle, 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, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, longKeyPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, 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, setPropertyValue, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
public static final int FIXED_NONE
public static final int FIXED_NONE_CYCLIC
public static final int FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE
public static final int FIXED_LEAD
public static final int FIXED_TRAIL
public static final int FIXED_CENTER
public static final int VERTICAL
public static final int HORIZONTAL
public List(Vector items)
items
- set of items placed into the list modelpublic List(T... items)
items
- set of items placed into the list modelpublic List()
public List(ListModel model)
model
- the model instancepublic static boolean isDefaultIgnoreFocusComponentWhenUnfocused()
public static void setDefaultIgnoreFocusComponentWhenUnfocused(boolean aDefaultIgnoreFocusComponentWhenUnfocused)
aDefaultIgnoreFocusComponentWhenUnfocused
- the defaultIgnoreFocusComponentWhenUnfocused to setpublic static boolean isDefaultFireOnClick()
public static void setDefaultFireOnClick(boolean aDefaultFireOnClick)
aDefaultFireOnClick
- the defaultFireOnClick to setprotected void initLaf(UIManager uim)
protected void laidOut()
protected void modelChanged(int status, int index)
status
- the type data change; REMOVED, ADDED or CHANGEDindex
- item index in a list modelprotected void listSelectionChanged(int oldSelected, int newSelected)
oldSelected
- the old selection valuenewSelected
- the new selection valuepublic int getSideGap()
getSideGap
in class Component
public boolean isScrollableY()
isScrollableY
in class Component
public boolean isScrollableX()
isScrollableX
in class Component
public int getMaxElementHeight()
public void setMaxElementHeight(int maxElementHeight)
maxElementHeight
- the maximum number of elementspublic int getMinElementHeight()
public void setMinElementHeight(int minElementHeight)
minElementHeight
- the minimum number of elementspublic int size()
public int getCurrentSelected()
public int getSelectedIndex()
public void setSelectedIndex(int index)
index
- the current selected offset in the listprotected Rectangle getVisibleBounds()
getVisibleBounds
in class Component
Component.getX()
,
Component.getY()
,
Component.getVisibleBounds(com.codename1.ui.geom.Rectangle)
protected int getDragRegionStatus(int x, int y)
getDragRegionStatus
in class Component
x
- x location for the touchy
- y location for the touchpublic void setSelectedIndex(int index, boolean scrollToSelection)
index
- the current selected offset in the listscrollToSelection
- indicates whether scrolling to selection should
occur if the selection is outside of viewpublic T getSelectedItem()
public void setSelectedItem(T item)
item
- the current selected item in the listpublic ListModel<T> getModel()
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
setShouldCalcPreferredSize
in class Component
shouldCalcPreferredSize
- indicate whether this component need to
recalculate his preferred sizepublic void setModel(ListModel model)
model
- the new model underlying the listpublic boolean isNumericKeyActions()
public void setNumericKeyActions(boolean numericKeyActions)
numericKeyActions
- true to trigger an action on number keyspublic boolean isCommandList()
public void setCommandList(boolean commandList)
commandList
- true for the list to be treated as a command listpublic boolean isIgnoreFocusComponentWhenUnfocused()
public void setIgnoreFocusComponentWhenUnfocused(boolean ignoreFocusComponentWhenUnfocused)
ignoreFocusComponentWhenUnfocused
- true to ignore the focus component false otherwisepublic boolean isMutableRendererBackgrounds()
public void setMutableRendererBackgrounds(boolean mutableRendererBackgrounds)
mutableRendererBackgrounds
- the new value for the flagpublic int getListSizeCalculationSampleCount()
public void setListSizeCalculationSampleCount(int listSizeCalculationSampleCount)
listSizeCalculationSampleCount
- the listSizeCalculationSampleCount to setpublic boolean isLongPointerPressActionEnabled()
public void setLongPointerPressActionEnabled(boolean longPointerPressAction)
longPointerPressAction
- the longPointerPressAction to setpublic void setRenderer(ListCellRenderer renderer)
renderer
- cell renderer instancepublic void setListCellRenderer(ListCellRenderer renderer)
renderer
- cell renderer instancepublic ListCellRenderer getRenderer()
public int getOrientation()
HORIZONTAL
,
VERTICAL
public void refreshTheme(boolean merge)
refreshTheme
in class Component
merge
- indicates if the current styles should be merged with the new stylespublic void setOrientation(int orientation)
orientation
- the list orientation HORIZONTAL or VERTICALHORIZONTAL
,
VERTICAL
public void scrollRectToVisible(Rectangle rect)
rect
- the rectangle area to scroll topublic void setHandlesInput(boolean b)
setHandlesInput
in class Component
b
- indicates whether key events can be grabbed for
focus traversalprotected void fireClicked()
fireClicked
in class Component
protected boolean isSelectableInteraction()
isSelectableInteraction
in class Component
public void keyReleased(int keyCode)
keyReleased
in class Component
keyCode
- the key code value to indicate a physical key.public void keyPressed(int keyCode)
keyPressed
in class Component
keyCode
- the key code value to indicate a physical key.public void paint(Graphics g)
protected boolean shouldRenderSelection()
public void addSelectionListener(SelectionListener l)
l
- the selection listener to be addedpublic void removeSelectionListener(SelectionListener l)
l
- the selection listener to be removedpublic void addActionListener(ActionListener l)
addActionListener
in interface ActionSource
l
- the action listener to be addedpublic Vector getActionListeners()
public Collection getListeners()
public void removeActionListener(ActionListener l)
removeActionListener
in interface ActionSource
l
- the action listener to be removedprotected void fireActionEvent()
protected void fireActionEvent(ActionEvent a)
a
- the event to firepublic void setInputOnFocus(boolean inputOnFocus)
inputOnFocus
- true is a list can start handling input
implicitly upon gaining focuspublic void setPaintFocusBehindList(boolean paintFocusBehindList)
paintFocusBehindList
- public int getItemGap()
public void setItemGap(int itemGap)
itemGap
- the gap between itemspublic void setRenderingPrototype(T renderingPrototype)
The rendering prototype is optionally used in calculating the size of the List and is recommended for performance reasons. You should invoke it with an object representing a theoretical value in the list which will be used to calculate the size required for each element in the list.
This allows list size calculations to work across look and feels and allows developers to predetermine size for list elements.
e.g. For a list of Strings which you would like to always be 5 characters wide you can use a prototype "XXXXX" which would use the preferred size of the XXXXX String to determine the size of the list element. E.g. for a list of dates you can use new Date(30, 12, 00) etc..
The example below was designed for MultiList
but
should work for any list. Its goal is to render 2 lines of text with 20 characters and a
5mm square icon:
renderingPrototype
- a value that can be passed to the renderer to indicate the preferred
size of a list component.public T getRenderingPrototype()
setRenderingPrototype(java.lang.Object)
public void longPointerPress(int x, int y)
longPointerPress
in class Component
public void pointerPressed(int x, int y)
pointerPressed
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerHover(int[] x, int[] y)
pointerHover
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerDragged(int x, int y)
pointerDragged
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic Rectangle getSelectedRect()
getSelectedRect
in class Component
public void setFireOnClick(boolean fireOnClick)
fireOnClick
- public void pointerHoverReleased(int[] x, int[] y)
pointerHoverReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinateprotected Dimension calcPreferredSize()
calcPreferredSize
in class Component
public void addItem(T item)
item
- the item to be added to a list modelpublic int getFixedSelection()
public void setFixedSelection(int fixedSelection)
fixedSelection
- one of: FIXED_NONE, FIXED_TRAIL, FIXED_LEAD,
FIXED_CENTER, FIXED_NONE_CYCLICpublic boolean animate()
Display
class.protected boolean isTactileTouch(int x, int y)
isTactileTouch
in class Component
x
- the x positiony
- the y positionpublic void setScrollToSelected(boolean scrollToSelected)
scrollToSelected
- if true the List scrolls to the selected element
when It's been initialized.protected int getGridPosY()
getGridPosY
in class Component
protected int getGridPosX()
getGridPosX
in class Component
protected String paramString()
null
.paramString
in class Component
public void setHint(String hint)
hint
- the hint text to displaypublic String getHint()
public void setHintIcon(Image icon)
icon
- the iconpublic Image getHintIcon()