|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j4me.ui.DeviceScreen
org.j4me.ui.Dialog
org.j4me.ui.Menu
public class Menu
The Menu
class is used for creating the application's menus.
J2ME devices have small screens and are not all very responsive to scrolling.
However, they do have keypads. The Menu
class respects this and
limits menus to a total of 9 possible choices (1-9) plus "Exit". Usually all
the choices can be seen on a single screen and selected with a single button.
Override this class to change how the menu is painted for your application.
Field Summary | |
---|---|
protected DeviceScreen |
previous
The screen that invoked this one or null if there is no
previous screen. |
Fields inherited from class org.j4me.ui.DeviceScreen |
---|
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, MENU_LEFT, MENU_RIGHT, RIGHT, UP |
Constructor Summary | |
---|---|
Menu()
Constructs a menu. |
|
Menu(java.lang.String name,
DeviceScreen previous)
Constructs a menu. |
Method Summary | |
---|---|
protected void |
acceptNotify()
The right menu button selects the highlighted menu item. |
void |
appendMenuOption(DeviceScreen option)
Appends a screen as a menu option. |
void |
appendMenuOption(MenuItem option)
Appends a new menu option to this menu. |
void |
appendMenuOption(java.lang.String text,
DeviceScreen option)
Appends a screen as a menu option. |
void |
appendSubmenu(Menu submenu)
Appends another menu as a menu option. |
protected void |
declineNotify()
The left menu button takes the user back to the previous screen. |
protected void |
keyPressed(int key)
Responds to key press events that are specific to menu screens. |
void |
setPrevious(DeviceScreen previous)
Sets the screen to return to if the user cancels this menu. |
Methods inherited from class org.j4me.ui.Dialog |
---|
append, components, delete, delete, deleteAll, get, getMargin, getSelected, getSpacing, getWidth, hasVerticalScrollbar, hideNotify, insert, invalidate, keyReleased, keyRepeated, paint, paintVerticalScrollbar, pointerDragged, pointerPressed, pointerReleased, set, setFullScreenMode, setMargin, setMenuText, setSelected, setSelected, setSpacing, setTitle, size |
Methods inherited from class org.j4me.ui.DeviceScreen |
---|
getCanvas, getHeight, getLeftMenuText, getRightMenuText, getScreenHeight, getScreenWidth, getTitle, hasMenuBar, hasTitleBar, intersects, isFullScreenMode, isShown, paintBackground, paintMenuBar, paintTitleBar, repaint, repaint, serviceRepaints, show, showNotify, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected DeviceScreen previous
null
if there is no
previous screen.
Constructor Detail |
---|
public Menu()
public Menu(java.lang.String name, DeviceScreen previous)
name
- is the title for this menu, for example "Main Menu". It
appears at the top of the screen in the title area.previous
- is the screen to return to if the user cancels this.Method Detail |
---|
public void setPrevious(DeviceScreen previous)
previous
is null
, there will be no "Cancel" button.
previous
- is the screen to go to if the user presses "Cancel".public void appendMenuOption(MenuItem option)
option
- is the menu item to add.public void appendMenuOption(DeviceScreen option)
option
- is screen to add as a menu item.public void appendMenuOption(java.lang.String text, DeviceScreen option)
text
- is string that appears in the menu option.option
- is screen to add as a menu item.public void appendSubmenu(Menu submenu)
To use a Menu
as a screen and not a submenu call the
appendMenuOption
method instead.
submenu
- is the screen to add as a menu item.protected void declineNotify()
declineNotify
in class DeviceScreen
DeviceScreen.getLeftMenuText()
protected void acceptNotify()
acceptNotify
in class DeviceScreen
DeviceScreen.getRightMenuText()
protected void keyPressed(int key)
FIRE
key is pressed. Scrolls from the last choice to
the first choice if DOWN
is pressed and from the first to
the last if UP
is pressed.
keyPressed
in class Dialog
key
- is the key code of the button the user pressed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |