textbox J2me

原创
2014/03/26 23:31
阅读数 14
 textbox

package com.soft.case1;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class password extends MIDlet implements CommandListener{
    private Display display;
    private Form form;
    private Command cmd;
    private Command cmd2;
    private TextBox textbox;
 public password() {
  // TODO Auto-generated constructor stub
 }

 protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  // TODO Auto-generated method stub

 }

 protected void pauseApp() {
  // TODO Auto-generated method stub

 }

 protected void startApp() throws MIDletStateChangeException {
  display=Display.getDisplay(this);
  form = new Form("FORM");
  cmd = new Command("ok",Command.OK,1);
  cmd2 = new Command("exit",Command.EXIT,1);
  textbox = new TextBox("qingshuru","",43,TextField.PASSWORD);
  textbox.addCommand(cmd);
  textbox.addCommand(cmd2);
  textbox.setCommandListener(this);
  display.setCurrent(textbox);//为什么这老是出错呢?

 }

 public void commandAction(Command arg0, Displayable arg1) {
  // TODO Auto-generated method stub
  if(arg0==cmd)
  {
   textbox.setConstraintd(TextField.ANY );
   textbox.setString("mima"+textbox.getString());
   textbox.removeCommand(cmd);
   
  }
  else if(arg0==cmd2)
  {
   try{
    
    destroyApp(false);
    this.notifyDestroyed();
    
   }catch(MIDletStateChangeException e){
    e.printStackTrace();
   }
   
  }
 }

}

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部