JavaMe连载(5)-绘制文本框TextEdit (十三)

2014-11-24 07:56:21 · 作者: · 浏览: 14
ST_EDIT,args);
break;
}
case KeyID.KEY_EDIT:
case KEY_NUM0:
case KEY_NUM1:
case KEY_NUM2:
case KEY_NUM3:
case KEY_NUM4:
case KEY_NUM5:
case KEY_NUM6:
case KEY_NUM7:
case KEY_NUM8:
case KEY_NUM9:
{
//System.out.println(editor);
Object[] args = {object_name,editor,username,passwd,passwd_re};
controller.handleEvent(UIController.EventID.EVENT_USER_REGIST_EDIT,args);
break;
}

UIController.java

[html] case EventID.EVENT_USER_REGIST_EDIT:
{
textBox.init(args);
midlet.setCurrent(textBox);
break;
}
case EventID.EVENT_USER_REGIST_EDIT:
{
textBox.init(args);
midlet.setCurrent(textBox);
break;
}

5 PopUpTextBox参数的接收

[html] public void init(Object[] args)
{
object_name = ((String)args[0]!=null) (String)args[0]:"";
editor = ((String)args[1]!=null) (String)args[1]:"";
//System.out.println(object_name);
//System.out.println(editor);
args_t = args;
this.setString("");
}
public void init(Object[] args)
{
object_name = ((String)args[0]!=null) (String)args[0]:"";
editor = ((String)args[1]!=null) (String)args[1]:"";
//System.out.println(object_name);
//System.out.println(editor);
args_t = args;
this.setString("");
}

6 PopUpTextBox返回输入法输入的值

[html] if (update) canvasText = this.getString();
if (update) canvasText = this.getString();

7 PopUpTextBox输入值处理

依据调用的对象,以及编辑对象,对输入的值进行处理,传递给父对象编辑框

[html] if(object_name.equals("registScreen"))
{
if(editor.equals("regist_name"))
{
if(args_t[3]!=""||args_t[3]!=null||args_t[4]!=""||args_t[4]!=null)
{
args[0] = object_name;
args[1] = editor;
args[2] = this.canvasText;
args[3] = args_t[3];
args[4] = args_t[4];
}
controller.handleEvent(UIController.EventID.EVENT_USER_REGIST_EDIT_BACK,args);
}
else if(editor.equals("regist_passwd"))
{
if(args_t[2]!=""||args_t[2]!=null||args_t[4]!=""||args_t[4]!=null)
{
args[0] = object_name;
args[1] = editor;
args[2] = args_t[2];
args[3] = this.canvasText;
args[4] = args_t[4];
}
controller.handleEvent(UIController.EventID.EVENT_USER_REGIST_EDIT_BACK,args);
}
else if(editor.equals("regist_passwd_re"))
{
if(args_t[2]!=""||args_t[2]!=null||args_t[3]!=""||args_t[3]!=null)
{
args[0] = object_name;
args[1] = editor;
args[2] = args_t[2];
args[3] = args_t[3];
args[4] = this.canvasText;
}
controller.handleEvent(UIController.EventID.EVENT_USER_REGIST_EDIT_BACK,args);
}
}
if(object_name.equals("registScreen"))
{
if(editor.equals("regist_name"))
{
if(args_t[3]!=""||args_t[3]!=null||args_t[4]!=""||args_t[4]!=null)
{
args[0] = object_name;
args[1] = editor;
args[2] = this.canvasText;
args[3] = args_t[3];
args[