📄 commandlistenertest1.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CommandListenerTest1 extends MIDlet implements CommandListener{
private Display display;
private Command changeCommand= new Command("Change",Command.OK,1);
private Form s1,s2;
public CommandListenerTest1() {
display=Display.getDisplay(this);
s1 = new Form("Screen1");
s1.addCommand(changeCommand);
s1.setCommandListener(this);
s2 = new Form("Screen2");
s2.addCommand(changeCommand);
s2.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
display.setCurrent(s1);
}
/**
* Pause the MIDlet
*/
public void pauseApp() {
}
/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
s1=null;
s2=null;
display=null;
}
public void commandAction(Command c,Displayable d) {
if(d==s1 && c==changeCommand) {
display.setCurrent(s2);
System.out.println("changed to screen 2");
}
else if(d==s2 && c==changeCommand) {
display.setCurrent(s1);
System.out.println("Changed to screen 1");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -