jMobileCore toolkit

com.jmobilecore.ui.core
Class List

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.Label
          extended by com.jmobilecore.ui.core.List
Direct Known Subclasses:
TimeZoneList

public class List
extends Label

The List component presents the user with a scrolling list of items.

Author:
Greg Gridin

Field Summary
 EventListener eventListener
          The event listener to receive events from this list.
protected  java.util.Vector items
          A vector created to contain items which will become part of the List.
protected  SoftKey leftKey
          The left soft key for the list screen
 ListScreen listScreen
          This screen displays list of values for the current List.
protected  SoftKey rightKey
          The right soft key for the list screen
protected  int selected
          The index of selected item.
protected  Label title
          The title for the list screen
 
Fields inherited from class com.jmobilecore.ui.core.Label
text
 
Fields inherited from class com.jmobilecore.ui.core.Component
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width
 
Constructor Summary
List()
          Creates a new scrolling list.
List(java.lang.String label)
          Creates a new scrolling list with the specified description
 
Method Summary
 void add(ListComponent item)
          Adds the specified item to the end of scrolling list.
 void add(ListComponent item, int index)
          Adds the specified string as ListLabel to the the scrolling list at the position indicated by the index.
 void add(java.lang.String text)
          Adds the specified string as ListLabel to the end of scrolling list.
 void add(java.lang.String text, int index)
          Adds the specified string as ListLabel to the the scrolling list at the position indicated by the index.
 ListScreen createListScreen()
          Creates new screen cantaining the list of list values.
 void deselect(int index)
          Deselects the item at the specified index.
 void destructor()
          Default destructor.
 ListComponent getComponent(int index)
          Gets the item associated with the specified index.
 java.lang.String getItem(int index)
          Gets the textual representation of an item associated with the specified index.
 int getItemCount()
          Gets the number of items in the list.
 ListComponent getSelectedComponent()
          Gets the selected item on this scrolling list.
 int getSelectedIndex()
          Gets the index of the selected item on the list,
 java.lang.String getSelectedItem()
          Gets the selected item on this scrolling list.
 boolean isIndexSelected(int index)
          Determines if the specified item in this scrolling list is selected.
protected  boolean keyPressed(int keyCode)
          Responds to key presses when the list has focus.
 void remove(int index)
          Remove the item at the specified position from this scrolling list.
 void remove(ListComponent item)
          Removes the first occurrence of an item from the list.
 void removeAll()
          Removes all items from this list.
 void replaceItem(java.lang.String newValue, int index)
          Replaces the item at the specified index in the scrolling list with the new string.
 void select(int index)
          Selects the item at the specified index in the scrolling list.
 void setListScreen(Label title, SoftKey leftKey, SoftKey rightKey)
           
 void setListScreen(java.lang.String titleText, java.lang.String backKeyText, java.lang.String selectKeyText)
           
 
Methods inherited from class com.jmobilecore.ui.core.Label
createTitleLabel, getText, paint, setText
 
Methods inherited from class com.jmobilecore.ui.core.Component
getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyReleased, keyRepeated, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont, setHeight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventListener

public EventListener eventListener
The event listener to receive events from this list. Events occur when a user pressed one of the soft buttons or shortcuts. If listener is null, no exception is thrown and no action is performed.


items

protected java.util.Vector items
A vector created to contain items which will become part of the List.


leftKey

protected SoftKey leftKey
The left soft key for the list screen

See Also:
SoftKey, ListScreen

listScreen

public ListScreen listScreen
This screen displays list of values for the current List.


rightKey

protected SoftKey rightKey
The right soft key for the list screen

See Also:
SoftKey, ListScreen

selected

protected int selected
The index of selected item. If the value is -1 then no items is selected


title

protected Label title
The title for the list screen

See Also:
ListScreen
Constructor Detail

List

public List()
Creates a new scrolling list.


List

public List(java.lang.String label)
Creates a new scrolling list with the specified description

See Also:
Label.setText(java.lang.String), Label.getText()
Method Detail

add

public void add(ListComponent item)
Adds the specified item to the end of scrolling list.

Parameters:
item - the item to be added

add

public void add(ListComponent item,
                int index)
Adds the specified string as ListLabel to the the scrolling list at the position indicated by the index. The index is zero-based.

Parameters:
item - the item to be added
index - the position at which to add the item

add

public void add(java.lang.String text)
Adds the specified string as ListLabel to the end of scrolling list.

Parameters:
text - the string to be added

add

public void add(java.lang.String text,
                int index)
Adds the specified string as ListLabel to the the scrolling list at the position indicated by the index. The index is zero-based.

Parameters:
text - the string to be added
index - the position at which to add the item

createListScreen

public ListScreen createListScreen()
Creates new screen cantaining the list of list values. Sets to focus state the currently selected item


deselect

public void deselect(int index)
Deselects the item at the specified index.

Parameters:
index - the position of the item to deselect

destructor

public void destructor()
Default destructor. Helps VM to perform garbage collection

Overrides:
destructor in class Component

getComponent

public ListComponent getComponent(int index)
Gets the item associated with the specified index.

Parameters:
index - the position of the item
Returns:
an item that is associated with the specified index

getItem

public java.lang.String getItem(int index)
Gets the textual representation of an item associated with the specified index.

Parameters:
index - the position of the item
Returns:
an item that is associated with the specified index

getItemCount

public int getItemCount()
Gets the number of items in the list.

Returns:
the number of items in the list

getSelectedComponent

public ListComponent getSelectedComponent()
Gets the selected item on this scrolling list.

Returns:
the selected item on the list, or null if no item is selected
See Also:
select(int), deselect(int), isIndexSelected(int)

getSelectedIndex

public int getSelectedIndex()
Gets the index of the selected item on the list,

Returns:
the index of the selected item
See Also:
select(int), deselect(int), isIndexSelected(int)

getSelectedItem

public java.lang.String getSelectedItem()
Gets the selected item on this scrolling list.

Returns:
the selected item on the list, or null if no item is selected
See Also:
select(int), deselect(int), isIndexSelected(int)

isIndexSelected

public boolean isIndexSelected(int index)
Determines if the specified item in this scrolling list is selected.

Parameters:
index - the item to be checked
Returns:
true if the specified item has been selected; false otherwise
See Also:
select(int), deselect(int)

keyPressed

protected boolean keyPressed(int keyCode)
Responds to key presses when the list has focus. When PlatformCanvas.KEY_ENTER button is pressed creates new screen that displays the list of list values

Overrides:
keyPressed in class Component
Parameters:
keyCode - The pressed key.

remove

public void remove(int index)
Remove the item at the specified position from this scrolling list.

Parameters:
index - the index of the item to delete

remove

public void remove(ListComponent item)
Removes the first occurrence of an item from the list.

Parameters:
item - the item to remove from the list

removeAll

public void removeAll()
Removes all items from this list.


replaceItem

public void replaceItem(java.lang.String newValue,
                        int index)
Replaces the item at the specified index in the scrolling list with the new string.

Parameters:
newValue - a new string to replace an existing item
index - the position of the item to replace

select

public void select(int index)
Selects the item at the specified index in the scrolling list.

Parameters:
index - the position of the item to select
See Also:
getSelectedItem(), deselect(int), isIndexSelected(int)

setListScreen

public void setListScreen(Label title,
                          SoftKey leftKey,
                          SoftKey rightKey)

setListScreen

public void setListScreen(java.lang.String titleText,
                          java.lang.String backKeyText,
                          java.lang.String selectKeyText)

jMobileCore toolkit