最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
j2me HelloWorld
时间:2022-07-02 17:43:41 编辑:袖梨 来源:一聚教程网
配置好Eclipse + KTW2.2环境后.实现在手机模拟器上显示HelloWorld字样
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)
{
}
}
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)
{
}
}
相关文章
- 时空中的绘旅人天宇之间怎么玩 绘旅人天宇之间活动玩法介绍 12-25
- QQ2024年度报告怎么看 2024qq年度报告玩法介绍 12-25
- 归龙潮珠砂什么时候up 归龙潮红缘绮梦卡池介绍 12-25
- 王者荣耀S38赛季有什么更新 12-25
- 王者荣耀S38赛季有什么更新 王者荣耀S38赛季更新内容介绍 12-25
- 世界之外12.25有什么更新 世界之外12月25日更新内容介绍 12-25