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

📄 navigatecanvas.java

📁 个很好的用来学习学习手机通信的例子
💻 JAVA
字号:
import javax.microedition.lcdui.*;

class NavigateCanvas extends Canvas {

    int width = 0;
    int height = 0;
	private Image image;
    private int   newX=0;
    private int   newY=0;

    public NavigateCanvas(Image image) {
        this.image=image;
        newX=0;
        newY=0;
    }

    public void steppingXY(int x, int y) {
            newX += x;
            newY += y;
    }

    public void paint(Graphics g) {
        width=this.getWidth();
        height=this.getHeight();

  	    g.setGrayScale(255);
	    g.fillRect(0,0,width-1,height-1);
	    g.setGrayScale(0);
        g.drawRect(0,0,width-1,height-1);

        g.translate(newX, newY);
        g.drawImage(image,0,0, g.TOP|g.LEFT);
    }
}

⌨️ 快捷键说明

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