GWT RootPanel没有交互

时间:2012-08-11 12:24:24

标签: gwt cordova

我创建了登录类:

public class LoginPage extends VerticalPanel implements ClickHandler {

ApplicationMethods appMthd;
private RootPanel rootPanel;
TextBox txtUserEmail;
PasswordTextBox txtPassword;

Button btnLogin;

String strEmail, strPass;

public LoginPage(ApplicationMethods appMthd) {

    this.appMthd = appMthd;

    rootPanel = RootPanel.get();
    rootPanel.setSize("320", "480");

    btnLogin = new Button("Login");
    btnLogin.setText("Login");
    rootPanel.add(btnLogin, 224, 256);
    btnLogin.setSize("79px", "35px");
    btnLogin.addClickHandler(this);


    txtUserEmail = new TextBox();
    rootPanel.add(txtUserEmail, 36, 161);
    txtUserEmail.setSize("240px", "20px");


    txtPassword = new PasswordTextBox();
    rootPanel.add(txtPassword, 36, 207);
    txtPassword.setSize("240px", "20px");
    }

@Override
public void onClick(ClickEvent event) {
    // TODO Auto-generated method stub

    if(event.getSource() == btnLogin)
    {
        strEmail = txtUserEmail.getText().toString();
        strPass = txtPassword.getText().toString();

        appMthd.onLogin(strEmail, strPass);
    }
    else
    {
        Window.alert("Coming Soon..!!");
    }
}

}

但我无法访问任何文本框或点击按钮。 因为Parent类是RootPanel。

如果我正在使用:

add(txtUserEmail);
    add(txtPassword);
    add(btnReg);
    add(btnLogin);
    btnLogin.addClickHandler(this);

然后,它是可访问的。在此,父类是VerticalPanel。

那么,我如何为RootPanel解决这个问题。?

请帮助我。

提前致谢。

1 个答案:

答案 0 :(得分:0)

使用VerticalPanel时,无法指定x,y 如果要指定x,y,当然可以扩展AbsolutePanel 但既然你是为移动设备编程,这是件好事。

如果您想使用phonegap和gwt创建移动应用程序

您应该查看mgwthello world mgwt

public LoginPage() {

    rootPanel = RootPanel.get();
    rootPanel.setSize("320", "480");
    rootPanel.add(this);

    btnLogin = new Button("Login");
    btnLogin.setText("Login");
    add(btnLogin);
    btnLogin.setSize("79px", "35px");
    btnLogin.addClickHandler(this);

    txtUserEmail = new TextBox();
    add(txtUserEmail);
    txtUserEmail.setSize("240px", "20px");

    txtPassword = new PasswordTextBox();
    add(txtPassword);
    txtPassword.setSize("240px", "20px");
}