setCurrentTest.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.lcdui.*;
- public class setCurrentTest extends MIDlet implements CommandListener {
- private Display display;
- private TextBox textBox;
- private Command cmd = new Command("null",Command.SCREEN,1);
- public setCurrentTest() {
- display = Display.getDisplay(this);
- textBox = new TextBox("Display演示","当前所显示的屏幕对象",50,0);
- textBox.addCommand(cmd);
- textBox.setCommandListener(this);
- }
- protected void startApp() {
- display.setCurrent(textBox);
- }
- protected void destroyApp(boolean unconditional) {
- }
- protected void pauseApp() {
- }
- public void commandAction(Command c, Displayable s) {
- System.out.println("调用display.setCurrent(textBox);");
- System.out.println("t当前显示屏幕对象为:"+display.getCurrent().toString());
- System.out.println("t当前对象是否可见:"+display.getCurrent().isShown());
- display.setCurrent(null);
- System.out.println("调用display.setCurrent(null);");
- System.out.println("t当前显示屏幕对象为:"+display.getCurrent().toString());
- System.out.println("t当前对象是否可见:"+display.getCurrent().isShown());
- display.setCurrent(display.getCurrent());
- System.out.println("调用display.setCurrent(display.getCurrent());");
- System.out.println("t当前显示屏幕对象为:"+display.getCurrent().toString());
- System.out.println("t当前对象是否可见:"+display.getCurrent().isShown());
- }
- }