mycanvas.java
来自「这是j2me的例子,可供初学者学习,里面有源代码,是我写的」· Java 代码 · 共 48 行
JAVA
48 行
/*
* MyCanvas.java
*
* Created on 2007年3月28日, 下午3:34
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.tan.ui.shap;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
/**
*
* @author USER
*/
public class MyCanvas extends Canvas implements CommandListener{
private Command exit;
private RectangleExample rectangleExample;
/** Creates a new instance of MyCanvas */
public MyCanvas(RectangleExample rectangleExample) {
this.rectangleExample = rectangleExample;
exit = new Command("Exit",Command.EXIT,1);
addCommand(exit);
setCommandListener(this);
}
protected void paint(Graphics graphics) {
graphics.setColor(255,255,255);
graphics.fillRect(0,0,getWidth(),getHeight());
graphics.setColor(255,0,0);
graphics.drawRect(2,2,20,20);
graphics.drawRoundRect(20,20,60,60,15,45);
}
public void commandAction(Command command, Displayable displayable) {
if(command == exit)
rectangleExample.exitMIDlet();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?