WEB开发网
开发学院软件开发Java 配置好Eclipse+WTK2.2环境后.实现在手机模拟器上显... 阅读

配置好Eclipse+WTK2.2环境后.实现在手机模拟器上显示HelloW

 2007-12-23 12:23:52 来源:WEB开发网   
核心提示:import javax.microedition.midlet.*;import javax.microedition.lcdui.*;//画布类,它实现了显示手机屏幕的内容class HelloCanvas extends Canvas{public HelloCanvas(){}public void paint

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

//画布类,它实现了显示手机屏幕的内容
class HelloCanvas extends Canvas
{
public HelloCanvas()
{
}

public void paint(Graphics g)
{
 g.setColor(255, 255, 255);
 g.fillRect(0, 0, getWidth(), getHeight());
 g.setColor(0, 0, 0);
 g.drawLine(10,10,50,50);
 g.drawString("Hello World!", 0, 0, Graphics.LEFT Graphics.TOP);
}
}

//MIDlet程序入口,显示画布
public class HelloWorld extends MIDlet implements CommandListener
{
PRivate HelloCanvas canvas_;
private Display display_;

public HelloWorld()
{
 canvas_ = new HelloCanvas();
}

public void startApp()
{
 display_ = Display.getDisplay(this);
 display_.setCurrent(canvas_);
 canvas_.repaint();
}

public void pauseApp()
{
}

public void destroyApp(boolean unconditional)
{
}

public void commandAction(Command c, Displayable s)
{
  }
}

(出处:http://www.cncms.com)


Tags:配置 Eclipse WTK

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接