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

2014-11-24 07:56:21 · 作者: · 浏览: 3
textEdit_name.height+margin+40, Graphics.TOP|Graphics.LEFT);
}

textEdit_passwd_x = 5;
textEdit_passwd_y = (info_wrap1.length+info_wrap2.length) * ft.getHeight()+textEdit_name.height+margin+40;
textEdit_passwd.drawTextBox(this, graphics, passwd, textEdit_passwd_x, textEdit_passwd_y, cursorBlinkOn2);

info = "密码确认:\n";
String info_wrap3[] = StringDealMethod.format(info, width-10, ft);

graphics.setFont(ft);
graphics.setColor(Color.text);
for(int i=0; i {
graphics.drawString(info_wrap3[i],5, (i+info_wrap1.length+info_wrap2.length) * ft.getHeight()+textEdit_name.height+textEdit_passwd.height+2*margin+40, Graphics.TOP|Graphics.LEFT);
}

textEdit_passwd_re_x = 5;
textEdit_passwd_re_y = (info_wrap1.length+info_wrap2.length+info_wrap3.length) * ft.getHeight()+textEdit_name.height+textEdit_passwd.height+2*margin+40;
textEdit_passwd_re.drawTextBox(this, graphics, passwd_re, textEdit_passwd_re_x, textEdit_passwd_re_y, cursorBlinkOn3);


}

public void clearScreen()
{
graphics.setColor(0xff,0xff,0xff);
graphics.fillRect(0, 0, width, height);
}

public void checkTimeStamp()
{
long currentTime = System.currentTimeMillis();
//System.out.println("1");
if(lastCaretBlink + caretBlinkDelay < currentTime)
{
//System.out.println("2");
if(editor.equals("regist_name"))
{
cursorBlinkOn1 =! cursorBlinkOn1;
cursorBlinkOn2 = false;
cursorBlinkOn3 = false;
}
else if(editor.equals("regist_passwd"))
{
cursorBlinkOn1 = false;
cursorBlinkOn2 =! cursorBlinkOn2;
cursorBlinkOn3 = false;
}
else if(editor.equals("regist_passwd_re"))
{
cursorBlinkOn1 = false;
cursorBlinkOn2 = false;
cursorBlinkOn3 =! cursorBlinkOn3;
}
lastCaretBlink = currentTime;
}
}

public void run()
{
//System.out.println("run");
while(true)
{
checkTimeStamp();

redraw();
try
{
synchronized(this)
{
//System.out.println("3");
wait(50L);
}
}
catch(Exception e)
{
e.printStackTrace();
}

}
}

protected void keyPressed(int keyCode)
{
switch(keyCode)
{
case KeyID.SOFT_RIGHT:
{
controller.handleEvent(UIController.EventID.EVENT_EXIT,null);
break;
}
case KeyID.SOFT_LEFT:
{
if(username!="" && passwd!=""&&passwd_re!="")
{
if(passwd.equals(passwd_re))
{


userReco