0

我创建了登录类:

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 解决这个问题。?

请帮助我。

提前致谢。

4

1 回答 1

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");
}
于 2012-08-14T09:01:29.830 回答