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

2014-11-24 07:56:21 · 作者: · 浏览: 1
rgs[3]!=null) (String)args[3]:"";
passwd_re = ((String)args[4]!=null) (String)args[4]:"";

if(editor.equals("regist_name"))
{
cursorBlinkOn1 = true;
cursorBlinkOn2 = false;
cursorBlinkOn3 = false;
currentlySelectedIndex =0;
}
else if(editor.equals("regist_passwd"))
{
cursorBlinkOn1 = false;
cursorBlinkOn2 = true;
cursorBlinkOn3 = false;
currentlySelectedIndex =1;
}
else if(editor.equals("regist_passwd_re"))
{
cursorBlinkOn1 = false;
cursorBlinkOn2 = false;
cursorBlinkOn3 = true;
currentlySelectedIndex =2;
}

//System.out.println(object_name);
//System.out.println(editor);
draw();
redraw();
}

public void draw()
{
//clearScreen();
backGroud.drawBackGroud(this, graphics);
head.drawHead(this,graphics,this.title);
menu.drawMenu(this,graphics,"下一步","退出");
drawBody();
}

private void redraw()
{
switch(currentlySelectedIndex)
{
case 0:
{
cursorBlinkOn2 = false;
cursorBlinkOn3 = false;
editor = "regist_name";
break;
}
case 1:
{
cursorBlinkOn1 = false;
cursorBlinkOn3 = false;
editor = "regist_passwd";
break;
}
case 2:
{
cursorBlinkOn1 = false;
cursorBlinkOn2 = false;
editor = "regist_passwd_re";
break;
}
default:;
}

textEdit_name.drawTextBox(this, graphics, username, textEdit_name_x, textEdit_name_y, cursorBlinkOn1);
textEdit_passwd.drawTextBox(this, graphics, passwd, textEdit_passwd_x, textEdit_passwd_y, cursorBlinkOn2);
textEdit_passwd.drawTextBox(this, graphics, passwd_re, textEdit_passwd_re_x, textEdit_passwd_re_y, cursorBlinkOn3);
textEdit_name.flushGraphics();
}

public void drawBody()
{
int margin =5;
ft = Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD,Font.SIZE_LARGE);

String info = "用户名:\n";
String info_wrap1[] = StringDealMethod.format(info, width-10, ft);

graphics.setFont(ft);
graphics.setColor(Color.text);
for(int i=0; i {
graphics.drawString(info_wrap1[i],5, (i) * ft.getHeight()+40, Graphics.TOP|Graphics.LEFT);
}

textEdit_name_x = 5;
textEdit_name_y = info_wrap1.length * ft.getHeight()+40;
textEdit_name.drawTextBox(this, graphics, username, textEdit_name_x, textEdit_name_y, cursorBlinkOn1);

info = "用户密码:\n";
String info_wrap2[] = StringDealMethod.format(info, width-10, ft);

graphics.setFont(ft);
graphics.setColor(Color.text);
for(int i=0; i {
graphics.drawString(info_wrap2[i],5, (i+info_wrap1.length) * ft.getHeight()+