最近開始學習為手機開發軟件了
今天上網搜索了一下相關資料
值得一提的是
今天寫的代碼
用於屏幕輸出的
前者屬於比較高級的控件
如果用後者
package hello;
import javax
import javax
public class HelloMIDlet extends MIDlet implements CommandListener {
private Command exitCommand; // The exit command
private Command view;
private Display display; // The display for this MIDlet
public HelloMIDlet() {
display = Display
exitCommand = new Command(
view = new Command(
}
public void startApp() {
TextBox t = new TextBox(
t
t
t
MyCanvas m=new MyCanvas();
if (System
t
else
t
display
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
package hello;
import javax
public class MyCanvas extends Canvas implements Runnable {
int count;
Font font;
public MyCanvas() {
Thread th=new Thread(this);
th
font=Font
}
//Drawing on canvas
public void paint(Graphics g) {
g
g
g
g
g
if(count==
{
g
}
else
{
g
g
g
g
}
}
//Handling keyEvents
protected void keyPressed(int keyCode) {
repaint();
}
public void run() {
while(true) {
count++;
try {
Thread
}catch(Exception e){}
repaint();
count%=
}
}
}
以上兩個文件經過編譯
通過藍牙上傳到我的dopod s
經過檢測
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26124.html