import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class MIDPApplication extends MIDlet
implements CommandListener{
Ticker newsTicker;
private List menuList; //主菜单
private List luckyList; //一周运势菜单
private List commList; //通讯簿菜单
private Command exitCommand; //离开
private Command execCommand; //执行
private Command menuCommand; //主目录
private Command commCommand; //通讯簿
private Command luckyCommand; //一周运势
private Command saveCommand; //存储
Form queryForm = null;
Form modificationForm = null;
Form deleteForm = null;
TextField nameField;
TextField EMailField;
TextField ageField;
String[] menuItem ={"通讯簿","一周运势"};
String[] commItem ={"新增","查询","修改","删除"};
String[] luckyItem ={"金牛座","处女座","摩羯座",
"射手座","牡羊座","狮子座",
"双鱼座","巨蟹座","天蝎座",
"双子座","天秤座","水瓶座"
};
Image[] menuImage = {createImage("/Sokoban.png"),
createImage("/Tiles.png")
};
//The display for this MIDlet
private Display display;
private String currentScreen = "";
public static String criteria = "";
private int deleteID = 0;
private int modificationID = 0;
public MIDPApplication() {
display = Display.getDisplay(this);
newsTicker = new Ticker("Java J2MIDP一书已出版 北京申奥成功");
exitCommand = new Command("离开", Command.EXIT, 1);
execCommand = new Command("执行",Command.OK, 1);
menuCommand = new Command("主目录",Command.SCREEN, 1);
commCommand = new Command("通讯簿",Command.SCREEN, 1);
luckyCommand = new Command("运势",Command.SCREEN,1);
}
public void startApp() {
menuList = new List(null,List.IMPLICIT,menuItem,menuImage);
menuList.setTicker(newsTicker);
menuList.addCommand(exitCommand);
menuList.setCommandListener(this);
display.setCurrent(menuList);
currentScreen="主目录";
}
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
if(c==List.SELECT_COMMAND){
if(currentScreen=="主目录"){
int itemIndex = menuList.getSelectedIndex();
switch(itemIndex){
case 0: {
doCommunication();
break;
}
case 1: doLucky();
}
}
else if(currentScreen=="通讯簿"){
int itemIndex = commList.getSelectedIndex();
switch(itemIndex){
case 0:{
doAppend();
break;
}
case 1:{
doQuery();
break;
}
case 2:{
doModification();
break;
}
case 3:{
doDelete();
break;
}
}
}
else{
}
}
if(c==menuCommand){
display.setCurrent(menuList);
currentScreen="主目录";
}
if(c==commCommand){
doCommunication();
}
if(c==luckyCommand){
doLucky();
}
if(c==menuCommand){
doMenu();
}
if(c==execCommand){
if(currentScreen=="一周运势"){
showLucky();
}
if(currentScreen=="通讯簿查询"){
this.criteria = nameField.getString();
doQueryPerson();
queryForm = null;
}
if(currentScreen=="通讯簿删除"){
doQueryPerson();
doDeletePerson(this.deleteID);
}
if(currentScreen=="通讯簿修改"){
modificationID = 0;
doQueryPerson();
if(!nameField.getString().equals("无此数据!")){
System.out.println("i am here"+ ":" + modificationID);
EMailField = new TextField("E Mail",null,30,TextField.EMAILADDR);
ageField = new TextField("年龄",null,3,TextField.NUMERIC);
saveCommand = new Command("存储",Command.SCREEN,1);
modificationForm.addCommand(saveCommand);
modificationForm.removeCommand(execCommand);
modificationForm.append(EMailField);
modificationForm.append(ageField);
}
else{
}
}
}
//------存储通讯簿的数据
if(c==saveCommand)
doSave();
}
private Image createImage(String name){
Image aImage = null;
try{
aImage = Image.createImage(name);
}
catch(IOException e){
}
return aImage;
}
private void doMenu(){
currentScreen="主目录";
display.setCurrent(menuList);
}
private void doCommunication(){
Image[] commIcon = {createImage("/StarCruiser.png"),
createImage("/Stock.png"),
createImage("/ManyBalls.png"),
createImage("/Tiles.png")
};
commList = new List("通讯簿",List.IMPLICIT,commItem,commIcon);
commList.addCommand(luckyCommand);
commList.addCommand(menuCommand);
commList.setCommandListener(this);
currentScreen="通讯簿";
display.setCurrent(commList);
}
private void doLucky(){
luckyList = new List("一周运势",List.EXCLUSIVE,luckyItem,null);
luckyList.addCommand(commCommand);
luckyList.addCommand(menuCommand);
luckyList.addCommand(execCommand);
luckyList.setCommandListener(this);
currentScreen="一周运势";
display.setCurrent(luckyList);
}
private void showLucky(){
int selectedItem = luckyList.getSelectedIndex();
Alert alert;
String information="";
switch(selectedItem){
case 0:{
information = "金牛座";
break;
}
case 1:{
information = "处女座";
break;
}
case 2:{
information = "摩羯座";
break;
}
case 3:{
information = "射手座";
break;
}
case 4:{
information = "牡羊座";
break;
}
case 5:{
information = "狮子座";
break;
}
case 6:{
information = "双鱼座";
break;
}
case 7:{
information = "巨蟹座";
break;
}
case 8:{
information = "天蝎座";
break;
}
case 9:{
information = "双子座";
break;
}
case 10:{
information = "天秤座";
break;
}
case 11:{
information = "水瓶座";
break;
}
}
alert = new Alert("资讯",information,null,AlertType.INFO);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
private void doAppend(){
Form appendForm = new Form("新增");
nameField = new TextField("姓名",null,8,TextField.ANY);
EMailField = new TextField("E Mail",null,30,TextField.EMAILADDR);
ageField = new TextField("年龄",null,3,TextField.NUMERIC);
saveCommand = new Command("存储",Command.SCREEN,1);
appendForm.append(nameField);
appendForm.append(EMailField);
appendForm.append(ageField);
appendForm.addCommand(saveCommand);
appendForm.addCommand(commCommand);
appendForm.addCommand(luckyCommand);
appendForm.addCommand(menuCommand);
appendForm.setCommandListener(this);
currentScreen = "通讯簿新增";
display.setCurrent(appendForm);
}
private void doModification(){
modificationForm = new Form("修改");
nameField = new TextField("姓名",null,10,TextField.ANY);
modificationForm.append(nameField);
modificationForm.addCommand(execCommand);
modificationForm.addCommand(commCommand);
modificationForm.addCommand(luckyCommand);
modificationForm.addCommand(menuCommand);
modificationForm.setCommandListener(this);
currentScreen = "通讯簿修改";
display.setCurrent(modificationForm);
}
private void doQuery(){
queryForm = new Form("查询");
nameField = new TextField("姓名",null,10,TextField.ANY);
queryForm.append(nameField);
queryForm.addCommand(execCommand);
queryForm.addCommand(commCommand);
queryForm.addCommand(luckyCommand);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
java-compcation.rar_J2ME 源码_j2me_手机移动通信_移动通信 (416个子文件)
modiperson.asp 1KB
updateperson.asp 1KB
modiperson2.asp 932B
newperson.asp 729B
stars.asp 721B
news.asp 559B
mainmenu.asp 550B
delperson.asp 513B
fetchNews.asp 387B
fetchStars.asp 378B
hello.asp 222B
all_http.asp 193B
hello2.asp 161B
MIDPApplication.class 15KB
MIDPApplication.class 14KB
MIDPApplication.class 12KB
MIDPApplication.class 11KB
MIDPApplication.class 7KB
MyCalendar.class 7KB
MIDPApplication.class 7KB
RecordMonitorMIDlet.class 7KB
FilterFieldsMIDlet.class 7KB
SortFieldsMIDlet.class 7KB
MainMIDlet.class 7KB
RetrieveAllMIDlet.class 7KB
QuotesMIDlet.class 7KB
MonthlyScheduleViewer.class 6KB
MyCalendar.class 6KB
MainMIDlet.class 6KB
QuotesMIDlet.class 6KB
MultiFieldsMIDlet.class 6KB
MonthlyScheduleViewer.class 6KB
RecordMonitorMIDlet.class 6KB
GuiTests.class 6KB
ListMIDlet.class 6KB
FilterFieldsMIDlet.class 6KB
SortFieldsMIDlet.class 6KB
GuiTests.class 6KB
HttpPOSTMIDlet.class 5KB
Scheduler.class 5KB
RetrieveAllMIDlet.class 5KB
ListMIDlet.class 5KB
Jargoneer$Poster.class 5KB
Scheduler.class 5KB
HttpPOSTMIDlet.class 5KB
MultiFieldsMIDlet.class 5KB
getRecordMIDlet.class 5KB
ResponseHeaderMIDlet.class 5KB
RecordIDMIDlet.class 5KB
ResponseHeaderMIDlet.class 5KB
Jargoneer$Poster.class 5KB
HttpGETMIDlet.class 5KB
HttpHEADMIDlet.class 4KB
ConnectHttpMIDlet.class 4KB
SynchOptionForm.class 4KB
HttpMIDlet.class 4KB
addRecordMIDlet.class 4KB
ConnectHttpMIDlet.class 4KB
SynchSetting.class 4KB
HttpHEADMIDlet.class 4KB
CalendarDB.class 4KB
SynchOptionForm.class 4KB
HttpCookieMIDlet.class 4KB
HttpGETMIDlet.class 4KB
getRecordMIDlet.class 4KB
SynchSetting.class 4KB
AppointmentForm.class 4KB
HttpMIDlet.class 4KB
AppointmentForm.class 4KB
SynchOption.class 4KB
RecordIDMIDlet.class 4KB
HttpCookieMIDlet.class 4KB
HttpOKMIDlet.class 4KB
RecordStore1MIDlet.class 4KB
addRecordMIDlet.class 4KB
CalendarDB.class 4KB
FewAlertsMIDlet.class 4KB
Appointment.class 4KB
HttpOKMIDlet.class 4KB
SynchOption.class 3KB
Appointment.class 3KB
FewAlertsMIDlet.class 3KB
CookieMIDlet.class 3KB
CookieMIDlet.class 3KB
RecordListenerTest.class 3KB
Jargoneer.class 3KB
CookieMIDlet.class 3KB
CookieMIDlet.class 3KB
ImageLoaderMIDlet.class 3KB
Jargoneer.class 3KB
StringItemMIDlet.class 3KB
StringItemMIDlet.class 3KB
ImageLoader.class 3KB
RecordStore1MIDlet.class 3KB
ImageLoaderMIDlet.class 3KB
FontCanvas.class 3KB
RecordListenerTest.class 3KB
ImageLoader.class 3KB
FontCanvas.class 3KB
RecordStoreList2.class 3KB
共 416 条
- 1
- 2
- 3
- 4
- 5
资源评论
朱moyimi
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功