?? mid.java
字號:
package j2me;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.Connector;
public class Mid extends MIDlet {
Form form;
public Mid() {
form=new Form("My Form");
Image image=null;
try {
image =createImage("http://202.117.68.5:8080/cupnet/bbs/attachment.php?s=&postid=13393");
}
catch (IOException ex) {
form=new Form("ERROR");
}
String strList[]={"First","Second","Third"};
Image[] imgList=new Image[]{image,image,image};
List list=new List("My List",List.EXCLUSIVE,strList,imgList);
form.append(image);
list.append("image:",image);
Display.getDisplay(this).setCurrent(form);
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void quitApp() {
destroyApp(true);
notifyDestroyed();
}
private Image createImage(String name) throws IOException {
if (name.startsWith("/")) {
// Load as a resource with Image.createImage
return Image.createImage(name);
} else if (name.startsWith("http:")) {
// Load from a ContentConnection
HttpConnection c = null;
DataInputStream is = null;
try {
c = (HttpConnection)Connector.open(name);
int status = c.getResponseCode();
if (status != 200) {
throw new IOException("HTTP Response Code = " + status);
}
int len = (int)c.getLength();
String type = c.getType();
if (!type.equals("image/png")) {
throw new IOException("Expecting image, received " + type);
}
if (len > 0) {
is = c.openDataInputStream();
byte[] data = new byte[len];
is.readFully(data);
return Image.createImage(data, 0, len);
} else {
throw new IOException("Content length is missing");
}
} finally {
if (is != null)
is.close();
if (c != null)
c.close();
}
} else {
throw new IOException("Unsupported media");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -