ВУЗ:
Составители:
Рубрика:
95
private void createMenu() {
String[] items = {"Store", "Favorites", "Exit"};
menuList = new List("Menu", List.IMPLICIT, items,
null);
menuList.addCommand(exitCommand);
menuList.setCommandListener(new CommandListener() {
public void commandAction(Command command, Dis-
playable d) {
if (command == List.SELECT_COMMAND) {
// Transfer to a screen depending on the selected item
int index = menuList.getSelectedIndex();
switch (index) {
case 0:
display.setCurrent(storeList);
break;
case 1:
dis-
play.setCurrent(favoriteList);
break;
default:
notifyDestroyed();
}
}
else if (command == exitCommand) {
// Exit the application
notifyDestroyed();
}
}
});
}
}
Form
Класс Form – это подкласс класса экран (Screen), который может
содержать произвольный набор компонентов пользовательского интер-
фейса, называемых items. Элементы, которые можно добавлять на
форму, должны расширять класс Item.
Класс Form можно создать с помощью следующих конструкторов:
public Form(String title);
public Form(String title, Item[] items);
Первый вариант позволяет создать пустую форму с заголовком
title, второй вариант с элементами пользовательского интерфейса
items.
Страницы
- « первая
- ‹ предыдущая
- …
- 93
- 94
- 95
- 96
- 97
- …
- следующая ›
- последняя »