如何将用户名和密码字段输入Blackberry文本框?

时间:2012-04-26 06:39:08

标签: java blackberry

如何在文本框中输入用户名和密码字段?

usernameField = new EditField("USERNAME:", "");
passwordField = new PasswordEditField("PASSWORD:", "");
add(usernameField);
vm.add(new LabelField("\n"));
add(passwordField);
ButtonField buttonField_1 = new ButtonField( "Login",ButtonField.FIELD_HCENTER );
add( buttonField_1 );   
ButtonField buttonField_2 = new ButtonField( "Forgot Password",ButtonField.FIELD_HCENTER );
add( buttonField_2 );   
buttonField_1.setMargin(100, 10, 10, 10);
//popup1();
buttonField_1.setChangeListener( new FieldChangeListener() {
    public void fieldChanged( Field arg0, int arg1 ) {
        if (usernameField.getTextLength() == 0 || passwordField.getTextLength() == 0) {
            Dialog.alert("You must enter a username and password");
        } else {
            profile();
        }
    }
});

buttonField_2.setChangeListener( new FieldChangeListener() {
    public void fieldChanged( Field arg0, int arg1 ) {
        UiApplication.getUiApplication().pushScreen(new Forgot_Pwd());
    }
});

2 个答案:

答案 0 :(得分:2)

http://keraisureshvblackberry.blogspot.in/2012/02/on-last-post-we-have-study-lablefiled.html

此博客可帮助您创建用户名和密码文本框

如果您从文件中获取文本而不是可以使用 usernameField.getText() passwordField.getText()

答案 1 :(得分:0)

TextField - show hint before user starts typing text

你可以尝试那个链接。它会帮助制作盒子,但即使我一直在努力创造一个与你建议相同的东西。如果有人有更多的想法,那将非常感激。

相关问题