www.pudn.com > java-game.rar > ViewWindowCanvas.java


//child_ViewWindowCanvas.java; 
//功能:完成菜单的定义及初始化; 
//类名:ViewWindowCanvas 
//作者:石明华 
//完成日期:2007-03-01 
 
import javax.microedition.lcdui.game.GameCanvas; 
import javax.microedition.lcdui.*; 
import java.io.IOException; 
 
public class ViewWindowCanvas extends GameCanvas implements Runnable{ 
 
	//定义List列表和文本框; 
	public List mainList;//菜单命令列表; 
	public TextBox tb; 
	Image icon; 
	Image main; 
	private Graphics g; 
	//private Display display; 
	Image[] imageArray = null; 
	protected ViewWindowCanvas() { 
		super(true); 
		// TODO Auto-generated constructor stub 
		try{ 
			main = Image.createImage("/dragon.png"); 
			icon = Image.createImage("/IconArrow.png"); 
			imageArray = new Image[]{icon,icon,icon,icon,icon,icon}; 
		}catch(IOException e){ 
			imageArray = null; 
		} 
		String[] stringArray = {"新游戏","游戏背景","游戏规则","参数设置","载入游戏","查看排名"}; 
		mainList = new List("海底大探险",Choice.IMPLICIT,stringArray,imageArray); 
	//	g.setColor(255,255,255); 
		try{ 
			g = this.getGraphics(); 
			g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_LARGE)); 
			g.drawString("海底大探险", this.getWidth()/2,50,Graphics.TOP|Graphics.HCENTER); 
			g.drawImage(main, this.getWidth()/2, this.getHeight()/2+main.getHeight()/2, Graphics.HCENTER|Graphics.BOTTOM); 
		}catch(Exception e){} 
	} 
 
	public void run() { 
		// TODO Auto-generated method stub 
	} 
 
	public void clear(){ 
		//mainList.append("asdfasd",icon); 
		g.setColor(255,255,255); 
		g.fillRect(0, 0, this.getWidth(), this.getHeight()); 
		g.setColor(0,0,0); 
	} 
}