?? savescreenmidlet.java.svn-base
字號:
package opusmicro.demos.canvas;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDlet;
public class SaveScreenMIDlet extends MIDlet implements CommandListener {
private Display display = null;
private SimpleCanvas canvas = new SimpleCanvas(true);
private Command printCommand = new Command("Print", Command.OK, 1);
public void startApp() {
if ( display == null) display = Display.getDisplay(this);
canvas.addCommand(printCommand);
canvas.setCommandListener(this);
display.setCurrent(canvas);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command command, Displayable displayable) {
if(command == printCommand){
Form form = new Form("screen");
form.append(canvas.printMe());
display.setCurrent(form);
}
}
}
class SimpleCanvas extends Canvas {
int w;
int h;
private Image offImage = null;
private boolean buffered = true;
public SimpleCanvas(boolean _buffered) {
buffered = _buffered;
w = getWidth();
h = getHeight();
if ( buffered) offImage = Image.createImage(w, h);
}
protected void paint(Graphics g) {
int color = g.getColor();
g.setColor(0xFFFFFF);
g.fillRect(0, 0, w, h);
g.setColor(color);
Graphics save = g;
if ( offImage != null) g = offImage.getGraphics();
// draw the offimage
g.setColor(128, 128, 0);
g.fillRoundRect((w - 100) / 2, (h - 60) / 2, 100, 60, 5, 3);
g.setColor(0xffeebb);
g.drawString("this is buffer", (w-100)/2, (h-60)/2, 0);
// draw the offimage to the canvas
save.drawImage(offImage, 0, 0, Graphics.TOP | Graphics.LEFT);
}
public Image printMe() {
return offImage;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -