lejos.nxt
Class TextMenu

java.lang.Object
  extended by lejos.nxt.TextMenu

public class TextMenu
extends Object

Displays a list of items. The select() method allows the user to scroll the list using the right and left keys to scroll forward and backward through the list. The location of the list , and an optional title can be specified.

Author:
Roger Glassey Feb 20, 2007

Field Summary
static String blank
          a blank line
 
Constructor Summary
TextMenu(String[] items)
          This constructor sets location of the top row of the item list to row 0 of the display.
TextMenu(String[] items, int topRow)
          This constructor allows specification location of the item list .
TextMenu(String[] items, int topRow, String title)
          This constuctor allows the specfication of a title (of up to 16 characters) and the location of the item list
The title is displayed in the row above the item list.
 
Method Summary
 String[] getItems()
          returns list of items in this menu;
 void quit()
          method to call from another thread to quit the menu
 void resetTimeout()
          Reset the timeout period.
 int select()
          Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item.
 int select(int selectedIndex)
          Version of select without timeout
 int select(int selectedIndex, int timeout)
          Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item.
 void setItems(String[] items)
          set the array of items to be displayed
 void setTitle(String title)
          set menu title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blank

public static String blank
a blank line

Constructor Detail

TextMenu

public TextMenu(String[] items)
This constructor sets location of the top row of the item list to row 0 of the display.


TextMenu

public TextMenu(String[] items,
                int topRow)
This constructor allows specification location of the item list .


TextMenu

public TextMenu(String[] items,
                int topRow,
                String title)
This constuctor allows the specfication of a title (of up to 16 characters) and the location of the item list
The title is displayed in the row above the item list.

Parameters:
items - - string array containing the menu items. No items beyond the first null will be displayed.
Method Detail

setTitle

public void setTitle(String title)
set menu title.

Parameters:
title - the new title

setItems

public void setItems(String[] items)
set the array of items to be displayed

Parameters:
items -

select

public int select()
Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item.
The menu display wraps items that scroll off the top will reappear on the bottom and vice versa. The selectedIndex is set to the first menu item.

Returns:
the index of the selected item

select

public int select(int selectedIndex)
Version of select without timeout


select

public int select(int selectedIndex,
                  int timeout)
Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item.
The menu display wraps items that scroll off the top will reappear on the bottom and vice versa. This version of select allows the selected index to be set when the menu is first displayed.

Parameters:
selectedIndex - the index to start the menu on
Returns:
the index of the selected item

quit

public void quit()
method to call from another thread to quit the menu


getItems

public String[] getItems()
returns list of items in this menu;

Returns:
the array of item names

resetTimeout

public void resetTimeout()
Reset the timeout period.