extra.ui
Class List

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--extra.ui.List
All Implemented Interfaces:
PreferredSize

public class List
extends Control
implements PreferredSize

This is a standard palm drop down list. It normally displays a down arrow followed by the currently selected item. When it is tapped it will drop down a list of all the options. When one of these is tapped, the list will fold back up with the new option displayed. A PRESSED event is also propogated down the hierachy. The selected string get be obtained with getSelected() and it's index with getSelectedIndex(). Items can be added to the list with the add() method.


Constructor Summary
List()
          Construct a new empty list of default size
List(String[] options)
          Construct a new list with the given options
List(Vector options)
          Construct a new list with the given options
 
Method Summary
 void add(String name)
          Add a new option to the end of the list
 boolean calcSizes()
           
 void drawList(Graphics g)
           
 int getPreferredHeight(FontMetrics fm)
           
 int getPreferredWidth(FontMetrics fm)
           
 String getSelected()
          Gets the text of the currently selected item
 int getSelectedIndex()
          Get the index of the currently selected option
 void onEvent(Event event)
          Process pen and key events to this component
 void onPaint(Graphics g)
          Called to draw the control.
 void setSelectedIndex(int i)
          Sets the currently selected index
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getFontMetrics, getNext, getParent, getRect, postEvent, removeTimer, repaint, setRect
 
Methods inherited from class java.lang.Object
equals, hashCode, toString
 

Constructor Detail

List

public List()
Construct a new empty list of default size

List

public List(String[] options)
Construct a new list with the given options
Parameters:
options - an array of the choices available

List

public List(Vector options)
Construct a new list with the given options
Parameters:
options - a vector of the choices available
Method Detail

add

public void add(String name)
Add a new option to the end of the list
Parameters:
name - the option to add

getSelected

public String getSelected()
Gets the text of the currently selected item

getSelectedIndex

public int getSelectedIndex()
Get the index of the currently selected option

setSelectedIndex

public void setSelectedIndex(int i)
Sets the currently selected index
Parameters:
i - the index of the item to select

getPreferredWidth

public int getPreferredWidth(FontMetrics fm)
Specified by:
getPreferredWidth in interface PreferredSize

getPreferredHeight

public int getPreferredHeight(FontMetrics fm)
Specified by:
getPreferredHeight in interface PreferredSize

calcSizes

public boolean calcSizes()

onPaint

public void onPaint(Graphics g)
Description copied from class: Control
Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted. The background is painted by the top-level window control.
Overrides:
onPaint in class Control
Following copied from class: waba.ui.Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

drawList

public void drawList(Graphics g)

onEvent

public void onEvent(Event event)
Process pen and key events to this component
Overrides:
onEvent in class Control
Parameters:
event - the event to process