simplegraphic.java

来自「《精通JAVA手机游戏与应用程序设计》随书光盘」· Java 代码 · 共 44 行

JAVA
44
字号

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;


public class SimpleGraphic extends MIDlet implements CommandListener {

	private Command exitCommand;
	private SimpleGraphicCanvas sg;

	public SimpleGraphic() {
		exitCommand = new Command("Exit", Command.EXIT, 1);
		sg = new SimpleGraphicCanvas();
		sg.addCommand(exitCommand);
		sg.setCommandListener(this);
		Display.getDisplay(this).setCurrent(sg);
		
	}
	protected void startApp(){
	}

	protected void pauseApp() {
	}

	protected void destroyApp(boolean arg0){		
	}
	public void commandAction(Command c, Displayable d) {
		if (c == exitCommand) {			
			destroyApp(false);			
			notifyDestroyed();
		}
	}	
}

class SimpleGraphicCanvas extends Canvas{
	
	protected void paint(Graphics g) {
		g.drawLine(0,0,50,50);
		g.drawRect(60,60,50,80);
		g.fillRect(65,65,30,40);
		
	}
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?