TextBox是一个容器类型的对象


   }
  
  public void destroyApp(boolean unconditional)
  {
   }
  
  public void pauseApp()
  {
  display.setCurrent(null);
  props = null;
   }
  
  }
   在上面的程序(CMD.java)中定义了八个命令。如果commandAction()方法接到这八个命令,多半是调用showScreen()方法,将这几个命令输出。showScreen()方法会产生一个新的容器对象(Form),作为当前的屏幕,并把截获的命令显示在屏幕中。
   CMD.java的运行效果如下2图所示(当屏幕出现Hello World字样的时候,你需要按下退出键,命令菜单就会出现了,你可以依次执行各个命令)。
  
  
  TextBox文本框对象
  发信站: 北大未名站 (2001年10月20日20:36:34 星期六) , 站内信件
  
   TextBox是一个容器类型的对象(和Form的性质一样)。用法如下所示:
  
  package fancy.test;
  
  import javax.microedition.midlet.*;
  import javax.microedition.lcdui.*;
  
  public class ShowTextBox extends MIDlet implements CommandListener
  {
  private Display display;
   private TextBox txtBox;
  
  private Command exitCommand = new Command("Exit", Command.EXIT, 1);
  
  public ShowTextBox()
  {
  display = Display.getDisplay(this);
   }
  
  public void startApp()
  {
  //or :
  //String str="hello world";
  //txtBox = new TextBox("Text Box",str,str.length(),0);
  //the follow code is wrong:
  //txtBox = new TextBox("Text Box",str,any number here,0);
  
  txtBox = new TextBox("Text Box",null,200,0);
  
  txtBox.addCommand(exitCommand);
  txtBox.setCommandListener(this);
  display.setCurrent(txtBox);
   }
  
  public void commandAction(Command c, Displayable s)
  {
  if (c == exitCommand)
  {
  destroyApp(false);
   notifyDestroyed();
  }
   }
  
  public void destroyApp(boolean unconditional)
  {
   }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值