|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlejos.util.TextMenu
public class TextMenu
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.
Field Summary | |
---|---|
protected int |
_height
number of rows displayed; set by constructor, used by display() |
protected String[] |
_items
array of items to be displayed ;set by constructor, used by select(); |
protected int |
_length
effective length of items array - number of items before null |
protected boolean |
_quit
boolean to cause select to quit |
protected int |
_startTime
start time for select() |
protected String |
_title
optional menu title displayed immediately above the list of items |
protected int |
_topIndex
index of the list item at the top of the list; set by constructor, used by select() |
protected int |
_topRow
location of the top row of the list; set by constructor, used by display() |
static String |
BLANK
a blank line |
protected static int |
BUTTON_POLL_INTERVAL
Timout used for Button.waitForAnyPress(int) in select(int, int) . |
protected static char |
SEL_CHAR
identifies the currently selected item |
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 | |
---|---|
protected void |
display(int selectedIndex,
int topIndex)
helper method used by select() |
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 |
---|
protected int _topRow
protected int _height
protected String _title
protected String[] _items
protected int _length
protected int _topIndex
protected static final char SEL_CHAR
public static final String BLANK
protected boolean _quit
protected int _startTime
protected static final int BUTTON_POLL_INTERVAL
Button.waitForAnyPress(int)
in select(int, int)
.
Constructor Detail |
---|
public TextMenu(String[] items)
public TextMenu(String[] items, int topRow)
public TextMenu(String[] items, int topRow, String title)
items
- - string array containing the menu items. No items beyond the first null will be displayed.Method Detail |
---|
public void setTitle(String title)
title
- the new titlepublic void setItems(String[] items)
items
- public int select()
public int select(int selectedIndex)
public int select(int selectedIndex, int timeout)
selectedIndex
- the index to start the menu on
public void quit()
protected void display(int selectedIndex, int topIndex)
public String[] getItems()
public void resetTimeout()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |