
| 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); //draw the offimage to the canvas save.drawImage(offImage,0,0,Graphics.TOP|Graphics.LEFT); } public Image printMe(){ return offImage; } |
| package com.J2MEdev; import Javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * * @author mingjava * @version */ public class PrintScreen 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); } } } |
|
|
| 关于我们 | 联系我们 | 广告服务 | 工作机会 | 版权声明 | 欢迎投稿 | 网站地图 |
| Copyright © 2000-2008 , www.21tx.com , All Rights Reserved . |
| © 晨新科技 版权所有 Created by TXSite.net |