www.pudn.com > 50code.rar > MyBack.java, change:2007-02-26,size:728b


package demo; 
import javax.microedition.lcdui.Graphics; 
import javax.microedition.lcdui.Image; 
 
public class MyBack { 
	private Image m_backImg;						//背景画面图像 
	 
	public MyBack(){ 
		try{				//读取背景图像 
			m_backImg = Image.createImage("/demo/back.png"); 
		} 
		catch (Exception ex){}  
	} 
	 
	/***** 
	 * 显示背景内容 
	 * @参数 g.............对应显示屏幕 
	 * @参数 scrWidth......屏幕的宽 
	 * @参数 scrHeight.....屏幕的高 
	 */ 
	public void Paint( Graphics g, int scrWidth, int scrHeight ){ 
		if( m_backImg != null ){ 
			//将背景显示到屏幕的中心 
			int x = ( scrWidth - m_backImg.getWidth() ) / 2; 
			int y = ( scrHeight - m_backImg.getHeight() ) / 2; 
			g.drawImage(m_backImg, x, y, 0 ); 
		} 
	} 
}