Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1228138
  • 博文数量: 699
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4970
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 13:45
文章分类

全部博文(699)

文章存档

2011年(1)

2008年(698)

我的朋友

分类:

2008-10-15 13:51:03

以下是引用片段:
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;
 }
--------------------next---------------------

阅读(397) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~