开发J2ME联网应用程序(5)

分类: J2ME   出处:iocblog整理  更新时间:2008-08-12   添加到收藏  


import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;


public class DisplayCanvas extends Form implements CommandListener
{
   private UIController uicontroller;
   private StringItem result;
   private int index = 0;
   private boolean first = true;
   public static Command backCommand = new Command("Back", Command.BACK, 2);

   public DisplayCanvas(UIController uicontroller)
   {
       super("Result");
       this.uicontroller = uicontroller;
       result = new StringItem("you have input:", null);
       this.addCommand(backCommand);
       this.setCommandListener(this);

   }

   public void init(String message)
   {
       if (first)
       {
           result.setText(message);
           index = this.append(result);
           first = false;
       }
       else
       {
           this.delete(index);
           result.setText(message);
           this.append(result);
       }

   }


   public void commandAction(Command arg0, Displayable arg1)
   {
       uicontroller.handleEvent(UIController.EventID.DISPLAY_BACK_TO_INPUT,
               null);

   }

}(来源www.iocblog.net)

上一页 [1] [2] [3] [4] [5]


Tag: 联网开发



文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。