当前位置: 代码迷 >> J2ME >> 请教Canvas作为方法参数如何画图呢
  详细解决方案

请教Canvas作为方法参数如何画图呢

热度:6084   发布时间:2013-02-25 21:34:21.0
请问Canvas作为方法参数怎么画图呢?
public void doCanvas(Canvas _Canvas){
 
  这边怎样用 paint(Graphics g)
 
  }

------解决方案--------------------------------------------------------
public void paintComponent(Graphics g) 
{
Graphics2D g2 = (Graphics2D)g;
super.paintComponent(g);
Image img = Toolkit.getDefaultToolkit().getImage("d:\\a.jpg");
g2.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
}