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

📄 fullcanvas.java

📁 Java ME手机应用开发大全一书的配套光盘上的源码
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class FullCanvas extends MIDlet
{
  private Display  display; 
  private MyCanvas canvas; 
  public FullCanvas ()
 {
    display = Display.getDisplay(this);
    canvas  = new MyCanvas (this);
  }
  protected void startApp()
  {
    display.setCurrent( canvas );
  }
  protected void pauseApp()
  { 
  }
  protected void destroyApp( boolean unconditional )
  { 
  }
  public void exitMIDlet()
  {
    destroyApp(true);
    notifyDestroyed();
  }
}
//定义画布类
class MyCanvas extends Canvas implements CommandListener
{
  private Command exit; 
  private FullCanvas Example;
  public MyCanvas (FullCanvas Example)
  {
    this.Example = Example;
    exit = new Command("Exit", Command.EXIT, 1);
    addCommand(exit);
    setCommandListener(this);
  } 
  //重写Canvas类的绘画方法
  protected void paint(Graphics graphics)
  {
      //将画笔颜色设置为白色
      graphics.setColor(255,255,255);
      //用白色填充整个画布范围,达到清屏的效果
      graphics.fillRect(0, 0, getWidth(), getHeight());
   }
  public void commandAction(Command command, Displayable displayable)
  {
    if (command == exit)
    {
     Example.exitMIDlet();
    }
  }
}

⌨️ 快捷键说明

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