📄 httpmidlet.java
字号:
package com;
/*
* HttpMidlet.java
*
* Created on 2007年4月12日, 下午3:27
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
/**
*
* @author chenzs
* @version
*/
public class HttpMidlet extends MIDlet implements CommandListener{
static HttpMidlet instance;
protected Display display;
protected List menuList;
protected Command cmdok;
protected Command cmdexit;
protected Command cmdback;
static final String strVisitURL="http://www.sina.com";
static final String strUploadURL = "http://211.157.4.*/upload/mobileupload.aspx";
static final String strDownURL = "http://211.157.4.*/upload/images";
static final String[] strMenuItem = {
"访问wap.baidu.com",
"上传数据",
};
public HttpMidlet(){
instance = this;
display = Display.getDisplay(this);
cmdok = new Command("OK", Command.OK, 1);
cmdexit = new Command("Exit", Command.EXIT, 1);
cmdback = new Command("Back", Command.BACK, 1);
Image img = null;
try{
img = Image.createImage("/res/icon.png");
}
catch(IOException e){
}
Image icon[] = {img ,img};
menuList = new List("请选择...", List.IMPLICIT, strMenuItem, icon);
menuList.addCommand(cmdok);
menuList.addCommand(cmdexit);
menuList.setCommandListener(this);
}
public void startApp() {
//display.setCurrent(new MIDPCanvas());
showMainList();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public static void quitApp(){
instance.destroyApp(true);
instance.notifyDestroyed();
}
//show menu
public void showMainList(){
display.setCurrent(menuList);
}
//download
public void showDown(){
}
public void commandAction(Command cmd , Displayable disp){
if(disp == menuList){
if(cmd.getCommandType()==Command.EXIT){
quitApp();
}
else if(cmd == List.SELECT_COMMAND || cmd.getCommandType()==Command.OK){
int index = menuList.getSelectedIndex();
switch(index){
case 0:
//visit joyhoo.com.cn
ViewForm vform = new ViewForm("Visit Internet", strVisitURL);
vform.addCommand(cmdback);
vform.setCommandListener(this);
display.setCurrent(vform);
break;
case 1:
//showUpload list
SelectList lst = new SelectList();
display.setCurrent(lst);
break;
case 2:
//download
ViewForm dform = new ViewForm("Visit data", strDownURL);
dform.addCommand(cmdback);
dform.setCommandListener(this);
display.setCurrent(dform);
break;
}//~end switch
}//~end if
}//~end if disp
else{
if(cmd.getCommandType() == Command.BACK)
showMainList();
if(cmd == List.SELECT_COMMAND){
//upload
UploadForm uForm = new UploadForm("Upload Image...", strUploadURL);
display.setCurrent(uForm);
}
}
}//~end commandAction
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -