?? viewimageui.java
字號:
package com.j2medev.ch8.mmapi;
import javax.microedition.lcdui.*;
public class ViewImageUI extends Form implements CommandListener{
private PowerCamera camera = null;
private byte[] image = null;//
private TextField title = new TextField("標題", "", 30, TextField.ANY);
private Command saveCommand = new Command("保存",Command.OK, 1);
private Command backCommand = new Command("返回",Command.BACK, 2);
public ViewImageUI(PowerCamera pc,byte[] img) {
super("照片");
this.camera = pc;
this.image = img;
Image temp = null;
//
temp = Image.createImage(image, 0, image.length);
this.append(temp);
this.append(title);
this.addCommand(saveCommand);
this.addCommand(backCommand);
this.setCommandListener(this);
}
public void backToPre(){
camera.releasePlayer();
camera.showCamera();//返回到攝像狀態
}
public void showInfo(String message,AlertType type){
Alert alert = new Alert("系統提示");
alert.setString(message);
alert.setTimeout(2000);
alert.setType(type);
Display.getDisplay(camera).setCurrent(alert, this);
}
public void commandAction(Command cmd,Displayable displayable){
if(cmd == backCommand){
this.backToPre();
}else if(cmd == saveCommand){
//
String label = title.getString();
Picture pic = new Picture(label, image);
camera.savePicture(pic);
showInfo("成功保存圖片到我的相冊", AlertType.CONFIRMATION);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -