⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycanvas.java

📁 这是j2me的例子,可供初学者学习,里面有源代码,是我写的
💻 JAVA
字号:
/*
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -