1 |
|
import javax.microedition.lcdui.Command; |
2 |
|
import javax.microedition.lcdui.CommandListener; |
3 |
|
import javax.microedition.lcdui.Display; |
4 |
|
import javax.microedition.lcdui.Displayable; |
5 |
|
import javax.microedition.lcdui.TextBox; |
6 |
|
import javax.microedition.midlet.MIDlet; |
7 |
|
import javax.microedition.midlet.MIDletStateChangeException; |
8 |
|
|
9 |
|
|
10 |
|
public class TestMIDlet extends MIDlet { |
11 |
|
|
12 |
|
private Command exitCommand; |
13 |
|
private Command infoCommand; |
14 |
|
|
15 |
|
TestMIDlet() { |
16 |
|
exitCommand = new Command("Exit", Command.SCREEN, 1); |
17 |
|
infoCommand = new Command("Info", Command.SCREEN, 2); |
18 |
|
} |
19 |
|
|
20 |
|
protected void destroyApp(boolean arg0) throws MIDletStateChangeException { |
21 |
|
} |
22 |
|
|
23 |
|
protected void pauseApp() { } |
24 |
|
|
25 |
|
protected void startApp() throws MIDletStateChangeException { |
26 |
|
TextBox t = new TextBox("FirstMIDlet", "Welcome to my Test", 256, 0); |
27 |
|
t.addCommand(exitCommand); |
28 |
|
t.addCommand(infoCommand); |
29 |
0 |
t.setCommandListener(new CommandListener() { |
30 |
|
|
31 |
|
public void commandAction(Command arg0, Displayable arg1) { |
32 |
0 |
if (arg0 == exitCommand) { |
33 |
0 |
notifyDestroyed(); |
34 |
|
} |
35 |
0 |
} |
36 |
|
}); |
37 |
|
Display.getDisplay(this).setCurrent(t); |
38 |
|
} |
39 |
|
} |