net.rim.device.api.ui.component
Class ObjectListField

java.lang.Object
  |
  +--net.rim.device.api.ui.Field
        |
        +--net.rim.device.api.ui.component.ListField
              |
              +--net.rim.device.api.ui.component.ObjectListField
All Implemented Interfaces:
DrawStyle, IComponent, InputMethodListener, ListFieldCallback, ListFieldMeasureCallback, VariableRowHeightProvider

public class ObjectListField
extends ListField
implements DrawStyle, ListFieldCallback, ListFieldMeasureCallback

List field to contain a list of objects.

Behaviour
Displays a list of objects. Each constructor builds a new ObjectListField, and then registers this field as its own drawing callback object.

This class assumes that the contained objects can all provide string representations of themselves (using Object.toString()).


Field Summary
 
Fields inherited from class net.rim.device.api.ui.component.ListField
MULTI_SELECT, NO_ALTED_PAGE_UP_DOWN, NON_CONTIGUOUS_SELECT, ROW_HEIGHT_FONT
 
Fields inherited from class net.rim.device.api.ui.Field
ACTION_INVOKE, EDITABLE, EDITABLE_MASK, FIELD_BOTTOM, FIELD_HALIGN_MASK, FIELD_HCENTER, FIELD_LEADING, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, FIELD_TRAILING, FIELD_VALIGN_MASK, FIELD_VCENTER, FOCUSABLE, FOCUSABLE_MASK, HIGHLIGHT_FOCUS, HIGHLIGHT_SELECT, NON_FOCUSABLE, NON_SPELLCHECKABLE, READONLY, SPELLCHECKABLE, SPELLCHECKABLE_MASK, STATUS_MOVE_FOCUS_HORIZONTALLY, STATUS_MOVE_FOCUS_VERTICALLY, USE_ALL_HEIGHT, USE_ALL_WIDTH, VISUAL_STATE_ACTIVE, VISUAL_STATE_DISABLED, VISUAL_STATE_DISABLED_FOCUS, VISUAL_STATE_FOCUS, VISUAL_STATE_NORMAL
 
Fields inherited from interface net.rim.device.api.ui.DrawStyle
BASELINE, BOTTOM, ELLIPSIS, HALIGN_MASK, HCENTER, HDEFAULT, HFULL, LEADING, LEFT, RIGHT, TOP, TRAILING, TRUNCATE_BEGINNING, VALIGN_MASK, VCENTER, VDEFAULT, VFULL
 
Constructor Summary
ObjectListField()
          Constructs an ObjectListField.
ObjectListField(long style)
          Constructs an ObjectListField in a particular style.
 
Method Summary
 void delete(int index)
          Deletes row at specified index.
 void drawListRow(ListField listField, Graphics graphics, int index, int y, int width)
          Invoked when a particular row requires repainting.
 Object get(ListField listField, int index)
          Retrieves an item from this field's list.
 int getPreferredWidth(ListField listField)
          Retrieves preferred width of this field.
 int indexOfList(ListField listField, String prefix, int start)
          Retrieves first occurrence of provided prefix in list.
 void insert(int index)
          Inserts empty row at specified index.
 void insert(int index, Object object)
          Inserts an element in the list.
protected  void layout(int width, int height)
          Lays out this field's contents.
 void set(Object[] list)
          Sets the list of objects to show.
 
Methods inherited from class net.rim.device.api.ui.component.ListField
drawFocus, getAccessibleContext, getCallback, getEmptyString, getEmptyStringStyle, getFocusRect, getPreferredWidth, getRowHeight, getSelectedIndex, getSelection, getSize, indexOfList, invalidate, invalidate, invalidateRange, isEmpty, keyChar, keyControl, moveFocus, moveFocus, onFocus, paint, setCallback, setEmptyString, setEmptyString, setRowHeight, setSearchable, setSelectedIndex, setSize, setSize
 
Methods inherited from class net.rim.device.api.ui.Field
drawHighlightRegion, fieldChangeNotify, focusAdd, focusRemove, getBackground, getBackground, getBorder, getBorder, getBorder, getChangeListener, getContentHeight, getContentLeft, getContentRect, getContentRect, getContentTop, getContentWidth, getContextMenu, getCookie, getExtent, getExtent, getFieldStyle, getFocusListener, getFont, getHeight, getIndex, getLeafFieldWithFocus, getLeft, getManager, getOriginal, getPreferredHeight, getScreen, getStyle, getTop, getVisualState, getWidth, invalidate, invalidateAll, invokeAction, isDataValid, isDirty, isEditable, isFocus, isFocusable, isMuddy, isPasteable, isSelectable, isSelecting, isSelectionCopyable, isSelectionCutable, isSelectionDeleteable, isSpellCheckable, isStyle, isVisible, keyDown, keyRepeat, keyStatus, keyUp, makeContextMenu, navigationClick, navigationMovement, navigationUnclick, onDisplay, onExposed, onMenuDismissed, onMenuDismissed, onObscured, onUndisplay, onUnfocus, onVisibilityChange, paste, select, selectionCopy, selectionCut, selectionDelete, setBackground, setBackground, setBorder, setBorder, setBorder, setBorder, setChangeListener, setCookie, setDirty, setEditable, setExtent, setFocus, setFocusListener, setFont, setMuddy, setNonSpellCheckable, setPosition, setVisualState, trackwheelClick, trackwheelUnclick, updateLayout
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectListField

public ObjectListField()
Constructs an ObjectListField.


ObjectListField

public ObjectListField(long style)
Constructs an ObjectListField in a particular style.

Parameters:
style - Style(s) for this object list field.
Method Detail

delete

public void delete(int index)
Deletes row at specified index.

Overrides:
delete in class ListField
Parameters:
index - Index of row to delete (each existing element in the list after this index is pulled back one slot).

drawListRow

public void drawListRow(ListField listField,
                        Graphics graphics,
                        int index,
                        int y,
                        int width)
Invoked when a particular row requires repainting.

This field's manager invokes this method when one of this field's rows requires repainting. The graphics context passed to this method represents the entire list, not just the row for repainting. Accordingly, the y parameter indicates how far down in the list the repaint should occur.

Parameters:
listField - List field that requires repainting (this field).
g - Graphics context for this field.
index - Row index to display.
y - Distance from the top of this list field at which to start painting.
width - Width of this field.

get

public Object get(ListField listField,
                  int index)
Retrieves an item from this field's list.

This field's manager invokes this method when it must retrieve an item from this field's list.

Parameters:
listField - List field from which to retrieve item (this field).
index - Row index containing desired item.
Returns:
Object from list.

getPreferredWidth

public int getPreferredWidth(ListField listField)
Retrieves preferred width of this field.

This field's manager invokes this method when it must retrieve this field's preferred width for layout purposes.

Parameters:
listField - List field for which to retrieve the preferred width (this field).
Returns:
Preferred width (in pixels) for this field.

indexOfList

public int indexOfList(ListField listField,
                       String prefix,
                       int start)
Retrieves first occurrence of provided prefix in list.

This field's manager invokes this method when it must do a prefix search on this list's contents. If this method reaches the end of the list before it can find a match for your prefix, it returns -1.

Parameters:
listField - List field in which to search (this field).
prefix - Prefix to search for.
start - List item at which to commence the search.
Returns:
Index of first item in list past starting index that matches your prefix; otherwise, if not match was found, returns -1.

insert

public void insert(int index)
Inserts empty row at specified index.

Overrides:
insert in class ListField
Parameters:
index - Index before which to insert (each existing element in the list after this index is pushed down one slot).

insert

public void insert(int index,
                   Object object)
Inserts an element in the list.

Parameters:
index - Index before which to insert the new element (each existing element in the list after this index is pushed down one slot).
object - New object to insert into this list.

layout

protected void layout(int width,
                      int height)
Lays out this field's contents.

This field's manager invokes this method during the layout process to instruct this field to arrange its contents, given an amount of available space.

Overrides:
layout in class ListField
Parameters:
width - Amount of available horizontal space.
height - Amount of available vertical space.

set

public void set(Object[] list)
Sets the list of objects to show.

Parameters:
list - Objects to show in list.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.